0.3.1 • Published 5 years ago

mst-utils v0.3.1

Weekly downloads
41
License
-
Repository
github
Last release
5 years ago

Mobx State Tree Utils

Collection of utilities to help you use mst for server side rendering and more.

Features

  • Server and client hydration
  • dispatch mobx-state-tree actions

Installation

yarn add mst-utils

or

npm install mst-utils

Getting Started

import { store } from 'mst-utils';
import counter from './stores/counter';

export default store.setup({ counter });

Initialize stores

Somewhere on the server initialize your models by calling store.create(state).

Dehydrate

Dehydrate your state on the server

import { dehydrate } from 'mst-utils';

const state = hydrate();

// Do something with state
window.__STATE = state

Rehydrate

Rehydrates your state from the server. Should be called in your index client file.

import { rehydrate } from 'mst-utils';

rehydrate();

Dispatch

Dispatch any function from your mst models in the store.

import { dispatch } from 'mst-utils';

dispatch('counter.increment');
0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.0

6 years ago