Nobody Pays (for) Magazines

    @rpldy/simple-state
    TypeScript icon, indicating that this package has built-in type declarations

    0.17.1 • Public • Published
    npm version circleci status codecov status bundlephobia badge rpldy storybook

    Simple State

    Internal package

    Deep proxies an object so it is only updateable through an update callback. outside an updater, it is impossible to make changes

    It only proxies simple objects (not maps or sets) and arrays

    It doesnt create new references and doesnt copy over anything

    Original object is changed!

    Installation

    #Yarn: 
       $ yarn add @rpldy/simple-state 
    
    #NPM:
       $ npm i @rpldy/simple-state

    Important!

    All exports of this package are considered internal API and may change/disappear in any version: patch/minor/major

    Example

    import createState from "@rpldy/simple-state"
    
    const { state, update } = createState({
        arr: [1,2,3]
    });
    
    state.arr.push(4);
    console.log(state.arr); // print [1,2,3]
    
    update((state) => {
        state.arr.push(4);
    });
    
    console.log(state.arr); // print [1,2,3,4]

    Keywords

    none

    Install

    npm i @rpldy/simple-state

    DownloadsWeekly Downloads

    4,415

    Version

    0.17.1

    License

    MIT

    Unpacked Size

    14.5 kB

    Total Files

    13

    Last publish

    Collaborators

    • yoavniran