mobx-server-wait
Render universally with server wait mobx actions.
Think of the scenario where you want to do some work in a promise. Once the work is complete, render the webpage.
Install
npm install --save mobx-server-wait
store.js
:
Usage in ;;; { ; ; } @observable planets = isLoading: false data: ; @serverWait { thisplanetsisLoading = true; const data = ; ; }
server.js
:
Usage in ;;; // Assuming you've created your server with expressapp;
Options for @serverWait
// Maximum wait time for individual action maxWait: <Number> || -1 // Retry rejected promise actions on the client retryRejected: <Boolean> || false
Options for serverWaitRender
// Maximum waiting time until the server calls the render method. maxWait: <Number> || 1250 // Attach debugger like debug: (...args) => console.log(...args); debug: <Function> || undefined // React component as root root: <ReactComponent> || undefined // Handled errors onError: <Function> || undefined // The mobx root store store: <Object> || {} // Render method render: <Function> || {} // Unique key to store promises map storeKey: <String> || 'serverWaitPromieses'
Licence
MIT