MCPcopy Create free account
hub / github.com/activejs/activejs / constructor

Method constructor

packages/core/src/lib/async-system.ts:34–97  ·  view source on GitHub ↗
(config?: AsyncSystemConfig<Query, Data, Error>)

Source from the content-addressed store, hash-verified

32 readonly config: Readonly<AsyncSystemConfig<Query, Data, Error>>;
33
34 constructor(config?: AsyncSystemConfig<Query, Data, Error>) {
35 super(
36 ...((() => {
37 config = {...Configuration.ASYNC_SYSTEM, ...config};
38 const {
39 id: systemId,
40 initialValue,
41 QUERY_UNIT,
42 DATA_UNIT,
43 ERROR_UNIT,
44 PENDING_UNIT,
45 UNITS,
46 }: AsyncSystemConfig<Query, Data, Error> = config;
47
48 const {queryUnitId, dataUnitId, errorUnitId, pendingUnitId} = generateAsyncSystemIds(
49 systemId,
50 QUERY_UNIT,
51 DATA_UNIT,
52 ERROR_UNIT,
53 PENDING_UNIT
54 );
55
56 // no need to check these, as Units ignore undefined as initialValue anyway
57 const {query, data, error, pending}: AsyncSystemValue<Query, Data, Error> =
58 initialValue || {};
59
60 const queryUnit = new GenericUnit<Query>({
61 initialValue: query,
62 ...UNITS,
63 ...QUERY_UNIT,
64 id: queryUnitId,
65 });
66
67 const dataUnit = new GenericUnit<Data>({
68 initialValue: data,
69 ...UNITS,
70 ...DATA_UNIT,
71 id: dataUnitId,
72 });
73
74 const errorUnit = new GenericUnit<Error>({
75 initialValue: error,
76 ...UNITS,
77 ...ERROR_UNIT,
78 id: errorUnitId,
79 });
80
81 const pendingUnit = new BoolUnit({
82 initialValue: pending,
83 ...UNITS,
84 ...PENDING_UNIT,
85 id: pendingUnitId,
86 });
87
88 return [queryUnit, dataUnit, errorUnit, pendingUnit, config];
89 })() as [
90 GenericUnit<Query>,
91 GenericUnit<Data>,

Callers

nothing calls this directly

Calls 1

generateAsyncSystemIdsFunction · 0.90

Tested by

no test coverage detected