Giter Club home page Giter Club logo

unissist's People

Contributors

btzr-io avatar dependabot[bot] avatar donniewest avatar kanaye avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

unissist's Issues

[Suggestion] Add hydration function.

Unissist already allows to modify the state when saving it through the map option.
In some cases it's usefull to also be able to modify the state while loading it.

[Suggestion] Allow async migration functions.

Allowing the migration function to return a promise would allow for different use cases.
For example to only import() (or otherwise load code) for migrations from the stores version.
This is usefull when you had lots of breaking changes in the store layout, but don't wan't to ship all migration code in the inital bundle.

To allow for showing user message the store could implement a migrating flag which is by default false.

To not further delay the store hydration, a check if the returned value is a promise could be made instead of always delaying the execution by a tick.

Edit: if you like the idea I could provide a PR within the next few days.

hydrated example

First of all - freaking awesome library.

// store state now includes a hydrated that tells you whether or not the state has been rehydrated from the store

Could you please elaborate what hydrated does and perhaps add a few lines of example code

Store refreshing to initial state using map instead of persisting old state.

Currently I have a separate store file that looks like this:

import createStore from 'unistore';
import persistStore from 'unissist';
import indexedDBAdapter from 'unissist/integrations/indexdbAdapter';
const initialState = {
    //data
};

const store = createStore(initialState);
const adapter = indexedDBAdapter();

const config = {
    debounceTime: 100,
    map: state => (
        {
            //data
        }   
    )
};
persistStore(store, adapter, config);

store.subscribe((state) => console.log(state));
export default store;

If I use persistStore(store, adapter) then it will refresh correctly, however using the map, it maps the new store it creates to the adapter then hydrates store. Should this be structured a different way? I am not sure why having the config map out state causes it to default to initial state instead of hydrating. Is there something here that would cause the map to run before it rehydrates?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.