UNPKG

unissist

Version:

A persistance library for unistore

3 lines (2 loc) 829 B
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.unissist=t()}(this,function(){return function(e,t,n){var i=(n=n||{}).version||1;e.setState({hydrated:!1}),Promise.resolve(t.getState()).then(function(t){!t||!t.version&&n.migration||t.version<i?n.migration?Promise.resolve(n.migration(t,i)).then(function(t){e.setState(Object.assign({},t,{hydrated:!0}))}):e.setState({hydrated:!0,version:i}):n.hydration?e.setState(Object.assign({},n.hydration(t),{hydrated:!0})):(t.hydrated=!0,e.setState(t))});var o,r=e.subscribe(function(){o||(o=setTimeout(function(){var r=e.getState();r.version=r.version||i,t.setState((n.map||Object)(r)),o=null},n.debounceTime||100))});return function(){r(),clearTimeout(o)}}}); //# sourceMappingURL=unissist.umd.js.map