Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
DatX is an opinionated data store for use with the MobX state management library. It features support for simple observable property definition, references to other models and first-class TypeScript support.
The library is still work in progress, but it's feature complete. You can track the v1.0 status using the v1.0 milestone.
import { Collection, Model, props } from 'datx';
import { computed } from 'mobx';
class Person extends Model {
public static type = 'person'; // Unique name of the model class
@prop name: string; // A normal observable property without a default value
@prop surname: string;
@prop.toOne(Person) spouse?: Person; // A reference to a Person model
@computed get fullName() { // Standard MobX computed props
return `${this.name} ${this.surname}`;
}
}
class AppData extends Collection {
public static types = [Person]; // A list of models available in the collection
}
const store = new AppData();
const john = store.add(new Person({name: 'John', surname: 'Smith'})); // Add a model instance to the store
const jane = store.add({name: 'Jane', surname: 'Smith', spouse: john}, Person); // Add a model to the store
Note: datx
has a peer dependency to mobx@^3.5.1
, so don't forget to install the latest MobX version:
npm install --save datx mobx
The library contains two main classes - Model
and Collection
.
A collection contains models of any kind (they should however be listed in the types
property), while a model can be in a single collection (but doesn't need to be in any).
Models also include some useful methods and properties, but if they're in collision with your data/logic, you can use a PureModel
class.
Mixins are additional plugins that can enhance the regular models and collections. Available mixins:
withActions
(model) - Adds some helper methods to the model - already included in the Model
class, but not in the PureModel
classwithMeta
(model) - Adds some helpful meta data to the model - already included in the Model
class, but not in the PureModel
classdatx-jsonapi
(model and collection) - Adds the JSON API features to the model and collectionTo check out what are the planed future mixins, check out the issues.
Want to make your own mixin? Check out the guide.
Package | npm version | dependency status | dev dependency status |
---|---|---|---|
datx | |||
datx-jsonapi | |||
datx-utils |
The MIT License
datx is maintained and sponsored by Infinum.
FAQs
A MobX data store
We found that datx demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.