![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.
Satchel is a dataflow framework based on the Flux architecture. It is characterized by exposing an observable state that makes view updates painless and efficient.
Satchel is an attempt to synthesize the best of several dataflow patterns typically used to drive a React-based UI. In particular:
There are a number of advantages to using Satchel to maintain your application state:
Install via NPM:
npm install satcheljs --save
In order to use Satchel with React, you'll also need MobX and the MobX React bindings:
npm install mobx --save
npm install mobx-react --save
The following examples assume you're developing in Typescript.
import { createStore } from 'satcheljs';
let getStore = createStore(
'todoStore',
{ todos: [] }
);
Notice the @observer
decorator on the component—this is what tells MobX to rerender the component whenever the data it relies on changes.
import { observer } from 'mobx-react';
@observer
class TodoListComponent extends React.Component<any, any> {
render() {
return (
<div>
getStore().todos.map(todo => <div>{todo.text}</div>)
</div>
);
}
}
Note that, as a convenience, Satchel action creators created with the action
API both create and dispatch the action.
This is typically how you want to use action creators.
If you want to create and dispatch the actions separately you can use the actionCreator
and dispatch
APIs.
import { action } from 'satcheljs';
let addTodo = action(
'ADD_TODO',
(text: string) => ({ text: text })
);
// This creates and dispatches an ADD_TODO action
addTodo('Take out trash');
You specify what action a mutator subscribes to by providing the corresponding action creator.
If you're using TypeScript, the type of actionMessage
is automatically inferred.
import { mutator } from 'satcheljs';
mutator(addTodo, (actionMessage) => {
getStore().todos.push({
id: Math.random(),
text: actionMessage.text
});
};
Orchestrators are like mutators—they subscribe to actions—but they serve a different purpose. While mutators modify the store, orchestrators are responsible for side effects. Side effects might include making a server call or even dispatching further actions.
The following example shows how an orchestrator can persist a value to a server before updating the store.
import { action, orchestrator } from 'satcheljs';
let requestAddTodo = action(
'REQUEST_ADD_TODO',
(text: string) => ({ text: text })
);
orchestrator(requestAddTodo, async (actionMessage) => {
await addTodoOnServer(actionMessage.text);
addTodo(actionMessage.text);
};
In many cases a given action only needs to be handled by one mutator or orchestrator. Satchel provides these utility APIs which encapsulate action creation, dispatch, and handling in one simple function call.
The addTodo
mutator above could be implemented as follows:
let addTodo = mutatorAction(
'ADD_TODO',
function addTodo(text: string) {
getStore().todos.push({
id: Math.random(),
text: actionMessage.text
});
});
An orchestrator can be created similarly:
let requestAddTodo = orchestratorAction(
'REQUEST_ADD_TODO',
async function requestAddTodo(text: string) {
await addTodoOnServer(actionMessage.text);
addTodo(actionMessage.text);
});
This is a succinct and easy way to write mutators and orchestrators, but it comes with a restriction: the action creator is not exposed, so no other mutators or orchestrators can subscribe to it. If an action needs multiple handlers then it must use the full pattern with action creators and handlers implemented separately.
FAQs
Store implementation for functional reactive flux.
The npm package satcheljs receives a total of 148 weekly downloads. As such, satcheljs popularity was classified as not popular.
We found that satcheljs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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.