0.1.5 • Published 4 years ago

@matchlighter/mobx_model v0.1.5

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

@matchlighter/mobx_model

A modern, extensible library for building client-side data models upon the principles of OOP.

Defining Models

import { Model, field } from '@matchlighter/mobx_model';

class User extends Model {
    @field full_name: string;
    @field({ /* options */ }) username: string;

    @collection({ type: 'local' }) projects: Project[] = [];
}

MobX

This library was originally built with MobX support built in out of the box. However, MobX support was refactored to a separate module before the first public release. MobX support can be enabled like such:

// ES6
import * as mobx from 'mobx';
import { initMobxCompat } from '@matchlighter/mobx_model';
initMobxCompat(mobx);

// CommonJS
const mobx = require('mobx');
const mobxModel = require('@matchlighter/mobx_model');
mobxModel.initMobxCompat(mobx);

With MobX support enabled,

  • @field automatically applies MobX @observable
  • @observable / @computed are automatically applied in other appropriate locations
  • Some other optimizations are made for supporting MobX & other features
0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

5 years ago