1.0.9 • Published 5 years ago

proxified_immutable v1.0.9

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Proxified Immutable

A wrapper for immutable.js using Javascript Proxy.

For the purpose of getting / selecting, iterating, key-checking state by a native Javascript object way.

Reducing the state is still by immutable.js APIs.

Example:

const ProxifiedImmutable = require('proxified_immutable');

const Immutable = require('immutable');

let initState = ProxifiedImmutable(Immutable.fromJS({
    workflows: {
        schemas: {
            workflow_id: {id: 1, name: 's1'},
            s2: {id: 2, name: 's2'}
        },
        instances: {},
        settings: {}
    }
}));

// get / select the state by a native Javascript object way
let selectedState = initState.workflows.schemas.workflow_id.id;  
// result: 1

// reduce the state by immutable.js API
let newStateBySetIn = initState.setIn(['workflows', 'schemas', 's3'], Immutable.fromJS({id: 3, name: 's3'}));
// result: a new proxy proxying the new immutable state

// iterate the selected state
selectedState = initState.workflows.schemas;
for (let key in selectedState) {
    console.log(key);
}
// result:
// workflow_id
// s2
// s3

// key-checking the selected state
if ('s3' in selectedState) {
    console.log('yes');
}

console.log('ok');
1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago