UNPKG

taggedjs

Version:

tagged template reactive html

64 lines (63 loc) 2.06 kB
import { Subject, ValueSubject } from '../subject/index.js'; import { getSupportInCycle } from '../tag/cycles/getSupportInCycle.function.js'; import { setUseMemory } from './setUseMemory.object.js'; import { state } from './state.function.js'; /** Create a Subject that on updates will sync state values to keep chained functions using latest variables */ export function subject(initialValue) { const support = getSupportInCycle(); if (support) { return state(() => new Subject(initialValue)); } return new Subject(initialValue); } subject._value = (value) => { state(function subjectValue() { return { state: setUseMemory.stateConfig.state, states: setUseMemory.stateConfig.states, }; }); //const nowSupport = getSupportInCycle() as AnySupport return state(function subjectValue() { const subject = new ValueSubject(value).pipe(x => { /* const context = nowSupport.context as SupportContextItem const stateMeta = context.state as ContextStateMeta const newer = stateMeta.newer as ContextStateSupport oldSyncStates( newer.state, oldestState.state, newer.states, oldestState.states, ) */ return x; }); return subject; }); }; function all(args) { state(() => ({ state: setUseMemory.stateConfig.state, states: setUseMemory.stateConfig.states, })); getSupportInCycle(); return Subject.all(args).pipe(x => { /* const context = nowSupport.context as SupportContextItem const stateMeta = context.state as ContextStateMeta const newer = stateMeta.newer if (newer) { oldSyncStates( newer.state, oldestState.state, newer.states, oldestState.states, ) } */ return x; }); } subject.all = all; //# sourceMappingURL=subject.function.js.map