![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
@codemaskinc/store
Advanced tools
- ⚛️ updates outside react components - 🪝 easy access to all store values - ✍️ no repeating yourself - ⚡️ no unnecessary rerenders - 🚀 typescript intellisense
Zustand is great, but you must write your own types for all stores (state, methods, etc.)
Jotai is also great, but you would most likely end up creating close to identical code for each store
([a, setA] = useAtom(aAtom), [b, setB] = useAtom(bAtom))
This simple createStore function solves all of those problems, using simple built in react api useSyncExternalStore, fast-deep-equal and some typescript magic 🪄
import { storage, createStore } from './store'
const { useStore } = createStore({
key1: 'value1',
key2: storage('value2')
})
const A = () => {
const { state, actions } = useStore('key1')
return <input value={state.hello} onChange={event => actions.setHello(event.target.value)} />
}
const B = () => {
const { state, actions } = useStore('key1', 'key2')
console.log(state.key1) // listens on value change
return <input value={state.key2} onChange={event => actions.setKey2(event.target.value)} />
}
const App = () => {
return (
<>
<A />
<br/>
<B />
</>
)
}
It takes object which is initial state of the store and returns:
Hook that allows to subscribe and update given properties of store, based on keys which you pass into it
const { useStore } = createStore({ test: 'some value' })
Returns current state of the store
const { getState } = createStore({ test: 'some value' })
console.log(getState().test) // "some value"
Object that contains of all actions to update store properties
const { getState, actions } = createStore({ test: 'some value' })
console.log(getState().test) // "some value"
actions.setTest('hello world')
console.log(getState().test) // "hello world"
Allows to synchronize store with localStorage
const { useStore } = createStore({
hello: storage<string>(), // string | undefined
test: storage('value'),
user: storage<User | null>(null, 'STORAGE_USER')
})
It takes two parameters, both are optional - initialValue
and storageKey
If you want pass storageKey into it, it will use the key that you've used as its name in initial store value (👆 hello and world are examples of that)
Synchronizer is util that allows to synchronize store with something external localStorage, database, device storage etc.
storage is example of it
type Synchronizer<T> = {
value: T,
subscribe: (update: (value: T) => void, key: string) => VoidFunction,
// If synchronizer doesn't have data that matches passed key, it should throw
getSnapshot: (key: string) => T | Promise<T>,
update: (value: T, key: string) => void
}
FAQs
- ⚛️ updates outside react components - 🪝 easy access to all store values - ✍️ no repeating yourself - ⚡️ no unnecessary rerenders - 🚀 typescript intellisense
The npm package @codemaskinc/store receives a total of 10 weekly downloads. As such, @codemaskinc/store popularity was classified as not popular.
We found that @codemaskinc/store demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers 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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.