v0.5.0
Add attribute casting. This is e.g. handy when you want to enforce that an attribute is always a moment
object, and when it is sent to the backend you want it to be a ISO-8601 string.
mobx-spine comes with two cast types at the moment datetime
and date
. Checkout the source code to see how easy it is to make your own cast.
import { Model, Casts } from 'mobx-spine';
class Animal extends Model {
@observable bornAt = null;
casts() {
return {
bornAt: Casts.datetime,
};
}
}