INNER CODE UNIT · TypeScript
publish
margelo/react-native-runtimes · packages/state/src/index.ts:426
function publish(nextState: TState, subtreeKey: string, revision: number) {
currentState = nextState;
subtreeRevisions.set(subtreeKey, revision);
currentRevision = Math.max(currentRevision, revision);
listeners.forEach(({ listener, subtreeKeys }) => {
if (shouldNotifyPath(subtreeKeys, subtreeKey)) {
listener(currentState, currentRevision, subtreeKey);
}
});
}
function patchPath<TValue>(subtreeKey: string, subtreeState: TValue): TState {
return setValueAtSegments(
currentState,
pathSegmentsFromKey(subtreeKey),
subtreeState,
);
}