
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
@abasb75/state-manager
Advanced tools
@abasb75/state-manager
is a great and best state manager tools for your javascript web applications.
localstorage
state
or defined action
npm i @abasb75/state-manager --save
initial value
for passing to store's object:
interface StateType {
darkMode:boolean;
counter:number;
notes:{
text:string;
date:number;
}[];
}
const initialState:StateType = {
darkMode:false,
counter:0,
notes:[],
}
actions
:
const actions = {
toggleDarkMode:(state:StateType)=>{
return {
...state,
darkMode:!state.darkMode,
};
},
counter:{
increment:(state:StateType)=>{
return {
...state,
counter:state.counter+1,
}
},
decrement:(state:StateType)=>{
return {
...state,
counter:state.counter-1,
}
},
},
notes:{
add:(state:StateType,text:string):StateType=>{
console.log('add worked!')
return {
...state,
notes:[
...state.notes,
{
text:text,
date:Date.now(),
}
]
}
},
delete:(state:StateType,id:number):StateType=>{
return {
...state,
notes:state.notes.filter(n=>n.date!==id),
}
},
}
}
import { createStore } from "@abasb75/state-manager";
...
const initialState:StateType = {
...
}
const actions = {
...
}
const store = createStore({
initialState,
actions,
storgable:true, // if storagble sets true, states saved on localstorage
storageKey:'mystorage',
});
export default store;
import store from './store';
get
method:
const state = store.get(); //return state
...
const state = store.get(state=>state.counter); //return counter value
set
method:
store.set({
counter:0;
}).then(state=>{
console.log(state.counter);
});
actions
:store.getActions().counter.increment();
subscribe
state changes:const unsubscribe = (state)=>{
console.log(state);
}
// subscribe return itself unsubscribe
unsubscribe();
// alternative for get subscriber:
const subscribeId = store.addSubscriber((state)=>{
console.log(state);
});
// and unsubscribe with subscribeId:
store.unsubscribe(subscribeId);
@abasb75/react-state-manager
is an extention to use this package in react.
FAQs
a javascript powerfull state manager
The npm package @abasb75/state-manager receives a total of 10 weekly downloads. As such, @abasb75/state-manager popularity was classified as not popular.
We found that @abasb75/state-manager demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.