This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
atom, | |
api, | |
injectPromise, | |
injectEffect, | |
injectSelf, | |
injectRef, | |
injectAtomValue, | |
injectAtomInstance, | |
injectSignal, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { api, atom, injectSignal } from "@zedux/react"; | |
export const debounceAtom = atom( | |
"debounce", | |
({ id, debounceTime = 1000 }: { id: string; debounceTime?: number }) => { | |
const debounceId = injectSignal(id); | |
const timeoutId = injectSignal<NodeJS.Timeout | null>(null); | |
return api(debounceId).setExports({ | |
debounce: (cb: () => void) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const availableSourcesAtom = atom("available-sources", () => { | |
const ecosystem = injectEcosystem(); | |
const transformItemToSignal = (item: SourceItem<TUnknownMeta>) => { | |
return ecosystem.signal(item); | |
}; | |
const callersSignal = injectMappedSignal( | |
constructKeyedObjectFromArray(callersData, transformItemToSignal), // transforms array in <Record<string, Signal<{Events: EventMap, State: T>}>>> | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const availableSourcesAtom = atom("available-sources", () => { | |
const signalItemEventsMap = { | |
create: console.log, | |
update: console.log, | |
destroy: console.log, | |
}; | |
const ecosystem = injectEcosystem(); | |
const transformItemToSignal = (item: SourceItem<TUnknownMeta>) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const createListContentAtom = atom( | |
"create-list-content", | |
(_id: string) => { | |
const viewSignal = injectAtomValue(createListViewAtom, [_id]); | |
const title = injectMemo(() => { | |
if (viewSignal === "financial-metrics") { | |
return "Financial Metrics"; | |
} | |
if (viewSignal === "tax-and-limits") { |