Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit ecf2a24

Browse files
committed
[@agile-ts/core] added public folders
1 parent 96cf923 commit ecf2a24

File tree

9 files changed

+127
-118
lines changed

9 files changed

+127
-118
lines changed

packages/core/src/collection/collection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
TrackedChangeMethod,
2121
} from './group';
2222
import { GroupIngestConfigInterface } from './group/group.observer';
23-
import { CreatePersistentConfigInterface, StorageKey } from '../storages';
23+
import { CreatePersistentConfigInterface } from '../storages';
2424
import { CollectionPersistent } from './collection.persistent';
2525

2626
export class Collection<DataType extends DefaultItem = DefaultItem> {
Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,9 @@
1-
import { Agile } from '../agile';
2-
import { shared } from '../shared';
3-
import { Collection, CreateCollectionConfig, DefaultItem } from './collection';
4-
51
export * from './collection';
62
export * from './collection.persistent';
73
export * from './group';
84
export * from './group/group.observer';
95
export * from './item';
106
export * from './selector';
117

12-
/**
13-
* Returns a newly created Collection.
14-
*
15-
* A Collection manages a reactive set of Information
16-
* that we need to remember globally at a later point in time.
17-
* While providing a toolkit to use and mutate this set of Information.
18-
*
19-
* It is designed for arrays of data objects following the same pattern.
20-
*
21-
* Each of these data object must have a unique `primaryKey` to be correctly identified later.
22-
*
23-
* You can create as many global Collections as you need.
24-
*
25-
* [Learn more..](https://agile-ts.org/docs/core/agile-instance/methods#createcollection)
26-
*
27-
* @public
28-
* @param config - Configuration object
29-
* @param agileInstance - Instance of Agile the Collection belongs to.
30-
*/
31-
export function createCollection<DataType extends DefaultItem = DefaultItem>(
32-
config?: CreateCollectionConfig<DataType>,
33-
agileInstance: Agile = shared
34-
): Collection<DataType> {
35-
return new Collection<DataType>(agileInstance, config);
36-
}
8+
// Outsourced from here because of tree shaking issues (See: https://github.com/agile-ts/agile/issues/196)
9+
export * from './public';

packages/core/src/collection/item.ts renamed to packages/core/src/collection/item/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import {
44
EnhancedState,
55
StateKey,
66
StateRuntimeJobConfigInterface,
7-
} from '../state';
8-
import { Collection, DefaultItem } from './collection';
9-
import { SelectorKey } from './selector';
10-
import { CollectionPersistent } from './collection.persistent';
7+
} from '../../state';
8+
import { Collection, DefaultItem } from '../collection';
9+
import { SelectorKey } from '../selector';
10+
import { CollectionPersistent } from '../collection.persistent';
1111

1212
export class Item<
1313
DataType extends DefaultItem = DefaultItem
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Collection, CreateCollectionConfig, DefaultItem } from '../collection';
2+
import { Agile } from '../../agile';
3+
import { shared } from '../../shared';
4+
5+
/**
6+
* Returns a newly created Collection.
7+
*
8+
* A Collection manages a reactive set of Information
9+
* that we need to remember globally at a later point in time.
10+
* While providing a toolkit to use and mutate this set of Information.
11+
*
12+
* It is designed for arrays of data objects following the same pattern.
13+
*
14+
* Each of these data object must have a unique `primaryKey` to be correctly identified later.
15+
*
16+
* You can create as many global Collections as you need.
17+
*
18+
* [Learn more..](https://agile-ts.org/docs/core/agile-instance/methods#createcollection)
19+
*
20+
* @public
21+
* @param config - Configuration object
22+
* @param agileInstance - Instance of Agile the Collection belongs to.
23+
*/
24+
export function createCollection<DataType extends DefaultItem = DefaultItem>(
25+
config?: CreateCollectionConfig<DataType>,
26+
agileInstance: Agile = shared
27+
): Collection<DataType> {
28+
return new Collection<DataType>(agileInstance, config);
29+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './createCollection';

packages/core/src/collection/selector.ts renamed to packages/core/src/collection/selector/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineConfig } from '@agile-ts/utils';
2-
import { EnhancedState, StateRuntimeJobConfigInterface } from '../state';
3-
import { Item } from './item';
4-
import { Collection, DefaultItem, ItemKey } from './collection';
2+
import { EnhancedState, StateRuntimeJobConfigInterface } from '../../state';
3+
import { Item } from '../item';
4+
import { Collection, DefaultItem, ItemKey } from '../collection';
55

66
export class Selector<
77
DataType extends DefaultItem = DefaultItem
Lines changed: 2 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,5 @@
1-
import { defineConfig } from '@agile-ts/utils';
2-
import { CreateAgileSubInstanceInterface, shared } from '../shared';
3-
import {
4-
Computed,
5-
ComputeFunctionType,
6-
CreateComputedConfigInterface,
7-
DependableAgileInstancesType,
8-
} from './computed';
9-
101
export * from './computed';
112
export * from './computed.tracker';
123

13-
/**
14-
* Returns a newly created Computed.
15-
*
16-
* A Computed is an extension of the State Class
17-
* that computes its value based on a specified compute function.
18-
*
19-
* The computed value will be cached to avoid unnecessary recomputes
20-
* and is only recomputed when one of its direct dependencies changes.
21-
*
22-
* Direct dependencies can be States and Collections.
23-
* So when, for example, a dependent State value changes, the computed value is recomputed.
24-
*
25-
* [Learn more..](https://agile-ts.org/docs/core/agile-instance/methods#createcomputed)
26-
*
27-
* @public
28-
* @param computeFunction - Function to compute the computed value.
29-
* @param config - Configuration object
30-
*/
31-
export function createComputed<ComputedValueType = any>(
32-
computeFunction: ComputeFunctionType<ComputedValueType>,
33-
config?: CreateComputedConfigInterfaceWithAgile
34-
): Computed<ComputedValueType>;
35-
/**
36-
* Returns a newly created Computed.
37-
*
38-
* A Computed is an extension of the State Class
39-
* that computes its value based on a specified compute function.
40-
*
41-
* The computed value will be cached to avoid unnecessary recomputes
42-
* and is only recomputed when one of its direct dependencies changes.
43-
*
44-
* Direct dependencies can be States and Collections.
45-
* So when, for example, a dependent State value changes, the computed value is recomputed.
46-
*
47-
* [Learn more..](https://agile-ts.org/docs/core/agile-instance/methods#createcomputed)
48-
*
49-
* @public
50-
* @param computeFunction - Function to compute the computed value.
51-
* @param deps - Hard-coded dependencies on which the Computed Class should depend.
52-
*/
53-
export function createComputed<ComputedValueType = any>(
54-
computeFunction: ComputeFunctionType<ComputedValueType>,
55-
deps?: Array<DependableAgileInstancesType>
56-
): Computed<ComputedValueType>;
57-
export function createComputed<ComputedValueType = any>(
58-
computeFunction: ComputeFunctionType<ComputedValueType>,
59-
configOrDeps?:
60-
| CreateComputedConfigInterfaceWithAgile
61-
| Array<DependableAgileInstancesType>
62-
): Computed<ComputedValueType> {
63-
let _config: CreateComputedConfigInterfaceWithAgile = {};
64-
65-
if (Array.isArray(configOrDeps)) {
66-
_config = defineConfig(_config, {
67-
computedDeps: configOrDeps,
68-
});
69-
} else {
70-
if (configOrDeps) _config = configOrDeps;
71-
}
72-
73-
_config = defineConfig(_config, { agileInstance: shared });
74-
75-
return new Computed<ComputedValueType>(
76-
_config.agileInstance as any,
77-
computeFunction,
78-
_config
79-
);
80-
}
81-
82-
export interface CreateComputedConfigInterfaceWithAgile
83-
extends CreateAgileSubInstanceInterface,
84-
CreateComputedConfigInterface {}
4+
// Outsourced from here because of tree shaking issues (See: https://github.com/agile-ts/agile/issues/196)
5+
export * from './public';
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import {
2+
Computed,
3+
ComputeFunctionType,
4+
DependableAgileInstancesType,
5+
} from '../computed';
6+
import { defineConfig } from '@agile-ts/utils';
7+
import { shared } from '../../shared';
8+
import { CreateComputedConfigInterfaceWithAgile } from './index';
9+
10+
/**
11+
* Returns a newly created Computed.
12+
*
13+
* A Computed is an extension of the State Class
14+
* that computes its value based on a specified compute function.
15+
*
16+
* The computed value will be cached to avoid unnecessary recomputes
17+
* and is only recomputed when one of its direct dependencies changes.
18+
*
19+
* Direct dependencies can be States and Collections.
20+
* So when, for example, a dependent State value changes, the computed value is recomputed.
21+
*
22+
* [Learn more..](https://agile-ts.org/docs/core/agile-instance/methods#createcomputed)
23+
*
24+
* @public
25+
* @param computeFunction - Function to compute the computed value.
26+
* @param config - Configuration object
27+
*/
28+
export function createComputed<ComputedValueType = any>(
29+
computeFunction: ComputeFunctionType<ComputedValueType>,
30+
config?: CreateComputedConfigInterfaceWithAgile
31+
): Computed<ComputedValueType>;
32+
/**
33+
* Returns a newly created Computed.
34+
*
35+
* A Computed is an extension of the State Class
36+
* that computes its value based on a specified compute function.
37+
*
38+
* The computed value will be cached to avoid unnecessary recomputes
39+
* and is only recomputed when one of its direct dependencies changes.
40+
*
41+
* Direct dependencies can be States and Collections.
42+
* So when, for example, a dependent State value changes, the computed value is recomputed.
43+
*
44+
* [Learn more..](https://agile-ts.org/docs/core/agile-instance/methods#createcomputed)
45+
*
46+
* @public
47+
* @param computeFunction - Function to compute the computed value.
48+
* @param deps - Hard-coded dependencies on which the Computed Class should depend.
49+
*/
50+
export function createComputed<ComputedValueType = any>(
51+
computeFunction: ComputeFunctionType<ComputedValueType>,
52+
deps?: Array<DependableAgileInstancesType>
53+
): Computed<ComputedValueType>;
54+
export function createComputed<ComputedValueType = any>(
55+
computeFunction: ComputeFunctionType<ComputedValueType>,
56+
configOrDeps?:
57+
| CreateComputedConfigInterfaceWithAgile
58+
| Array<DependableAgileInstancesType>
59+
): Computed<ComputedValueType> {
60+
let _config: CreateComputedConfigInterfaceWithAgile = {};
61+
62+
if (Array.isArray(configOrDeps)) {
63+
_config = defineConfig(_config, {
64+
computedDeps: configOrDeps,
65+
});
66+
} else {
67+
if (configOrDeps) _config = configOrDeps;
68+
}
69+
70+
_config = defineConfig(_config, { agileInstance: shared });
71+
72+
return new Computed<ComputedValueType>(
73+
_config.agileInstance as any,
74+
computeFunction,
75+
_config
76+
);
77+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { CreateAgileSubInstanceInterface } from '../../shared';
2+
import { CreateComputedConfigInterface } from '../computed';
3+
4+
export * from './createComputed';
5+
6+
export interface CreateComputedConfigInterfaceWithAgile
7+
extends CreateAgileSubInstanceInterface,
8+
CreateComputedConfigInterface {}

0 commit comments

Comments
 (0)