Get started with seamless-immutable CDN
BSD-3-Clause licensed
Immutable data structures with seamless API . Efficient, predictable updates without deep cloning.
Tags:- immutable
Stable version
Copied!
How to start using seamless-immutable CDN
// Include Seamless Immutable library
const IM = window.SeamlessImmutable;
// Create an initial immutable state
const initialState = IM.Map({
count: IM.Int(0),
name: IM.String('John Doe'),
});
// Create a reducer function
const reducer = (state, action) => {
switch (action.type) {
case 'INCREMENT':
return state.set('count', state.get('count').increment(1));
case 'SET_NAME':
return state.set('name', IM.String(action.payload));
default:
throw new Error();
}
};
// Create a store using the reducer and initial state
const store = IM.State(reducer, initialState);
// Dispatch actions to update the state
store.dispatch({ type: 'INCREMENT' });
store.dispatch({ type: 'SET_NAME', payload: 'Jane Doe' });
// Get the current state
const currentState = store.getState();
// Update the state directly (not recommended)
store.set('count', store.get('count').increment(1));
console.log(currentState.toJS()); // { count: 1, name: 'Jane Doe' }
Copied!
Copied!
Copied!
All versions
0.1.0
0.2.0
0.2.1
0.3.0
0.3.1
0.3.2
0.4.0
0.4.1
0.5.0
1.0.0
1.0.1
1.1.0
1.1.2
1.2.0
1.3.0
2.0.0
2.0.1
2.0.2
2.1.0
2.2.0
2.3.0
2.3.1
2.3.2
2.4.0
2.4.1
2.4.2
3.0.0
4.0.0
4.0.1
4.0.2
4.1.0
4.1.1
5.0.0
5.0.1
5.1.0
5.1.1
5.2.0
6.0.0
6.0.1
6.1.0
6.1.1
6.1.2
6.1.3
6.1.4
6.2.0
6.3.0
7.0.1
7.1.1
7.1.2
7.1.3
*** 7.1.4