All Projects → infinum → Datx

infinum / Datx

Licence: mit
DatX is an opinionated JS/TS data store. It features support for simple property definition, references to other models and first-class TypeScript support.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Datx

mutable
State containers with dirty checking and more
Stars: ✭ 32 (-71.17%)
Mutual labels:  state-management, mobx, model
Mithril Data
A rich data model library for Mithril javascript framework
Stars: ✭ 17 (-84.68%)
Mutual labels:  data, collection, model
Mobx State Tree
Full-featured reactive state management without the boilerplate
Stars: ✭ 6,317 (+5590.99%)
Mutual labels:  state-management, mobx
Flight Prices Scraper
Automated Script to scrape flight prices from any website into a csv format
Stars: ✭ 17 (-84.68%)
Mutual labels:  data, collection
Kakajson
Fast conversion between JSON and model in Swift.
Stars: ✭ 867 (+681.08%)
Mutual labels:  data, model
React Coat
Structured React + Redux with Typescript and support for isomorphic rendering beautifully(SSR)
Stars: ✭ 290 (+161.26%)
Mutual labels:  state-management, mobx
Blue Chip
Normalizes GraphQL and JSON:API payloads into your state management system and provides ORM selectors to prepare data to be consumed by components
Stars: ✭ 332 (+199.1%)
Mutual labels:  state-management, mobx
Modelassistant
Elegant library to manage the interactions between view and model in Swift
Stars: ✭ 26 (-76.58%)
Mutual labels:  data, model
react-coat-ssr-demo
Demo with Typescript + React + Redux for server-side-rendering (SSR)
Stars: ✭ 100 (-9.91%)
Mutual labels:  state-management, mobx
Flutter Boilerplate Project
A boilerplate project created in flutter using MobX and Provider.
Stars: ✭ 1,194 (+975.68%)
Mutual labels:  state-management, mobx
Muster
A universal data layer for components and services
Stars: ✭ 59 (-46.85%)
Mutual labels:  data, state-management
Compare React State Management
React createContext vs Apollo vs MobX vs Redux in a simple todo app.
Stars: ✭ 81 (-27.03%)
Mutual labels:  state-management, mobx
Mobx Keystone
A MobX powered state management solution based on data trees with first class support for Typescript, support for snapshots, patches and much more
Stars: ✭ 284 (+155.86%)
Mutual labels:  state-management, mobx
mobx-collection-store
Data collection store for MobX
Stars: ✭ 36 (-67.57%)
Mutual labels:  collection, mobx
Westore
更好的小程序项目架构
Stars: ✭ 3,897 (+3410.81%)
Mutual labels:  state-management, model
micro-observables
A simple Observable library that can be used for easy state management in React applications.
Stars: ✭ 78 (-29.73%)
Mutual labels:  state-management, mobx
Covid19 scenarios
Models of COVID-19 outbreak trajectories and hospital demand
Stars: ✭ 1,355 (+1120.72%)
Mutual labels:  data, model
hooksy
Simple app state management based on react hooks
Stars: ✭ 58 (-47.75%)
Mutual labels:  state-management, mobx
Mobx Jsonapi Store
JSON API Store for MobX
Stars: ✭ 52 (-53.15%)
Mutual labels:  data, mobx
Reactstatemuseum
A whirlwind tour of React state management systems by example
Stars: ✭ 1,294 (+1065.77%)
Mutual labels:  state-management, mobx

DatX

Unit tests

DatX is an opinionated JS/TS data store. It features support for simple property definition, references to other models and first-class TypeScript support.

By default, it uses the MobX state management library, but this is optional and can be used as a pure JS library.


Basic usage

import { Collection, Model, Attribute } from '@datx/core';
import { computed } from 'mobx';

class Person extends Model {
  public static type = 'person'; // Unique name of the model class

  @Attribute() 
  public name!: string; // A normal property without a default value
  
  @Attribute()
  public surname!: string;
  
  @Attribute({ toOne: Person })
  public spouse?: Person; // A reference to a Person model

  @computed
  public 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

Getting started

npm install --save @datx/core

Polyfilling

The lib makes use of the following features that are not yet available everywhere. Based on your browser support, you might want to polyfill them:

How to add the polyfills.

Concepts

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

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 class
  • withMeta (model) - Adds some helpful meta data to the model - already included in the Model class, but not in the PureModel class
  • withPatches (model, collection) - Adds patch support to models and collections
  • datx-jsonapi (model, collection and view) - Adds the JSON API features to the model, collection and view

To check out what are the planed future mixins, check out the issues.

Want to make your own mixin? Check out the guide.

API reference

Troubleshooting

Having issues with the library? Check out the troubleshooting page or open an issue.


Build Status

License

The MIT License

Credits

datx is maintained and sponsored by Infinum.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].