Skip to content

v0.5.0

Compare
Choose a tag to compare
@SpaceK33z SpaceK33z released this 23 Mar 10:46
· 290 commits to master since this release

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,
        };
    }
}