|
1 | | -import { defineConfig, removeProperties } from '@agile-ts/utils'; |
2 | | -import { CreateAgileSubInstanceInterface, shared } from '../shared'; |
3 | | -import { State, StateConfigInterface } from './state'; |
4 | | -import { EnhancedState } from './state.enhanced'; |
5 | | - |
6 | 1 | export * from './state'; |
7 | 2 | export * from './state.observer'; |
8 | 3 | export * from './state.enhanced'; |
9 | 4 | export * from './state.persistent'; |
10 | 5 | export * from './state.runtime.job'; |
11 | 6 |
|
12 | | -/** |
13 | | - * Returns a newly created State. |
14 | | - * |
15 | | - * A State manages a piece 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 piece of Information. |
18 | | - * |
19 | | - * You can create as many global States as you need. |
20 | | - * |
21 | | - * [Learn more..](https://agile-ts.org/docs/core/agile-instance/methods#createstate) |
22 | | - * |
23 | | - * @public |
24 | | - * @param initialValue - Initial value of the State. |
25 | | - * @param config - Configuration object |
26 | | - */ |
27 | | -export function createLightState<ValueType = any>( |
28 | | - initialValue: ValueType, |
29 | | - config: CreateStateConfigInterfaceWithAgile = {} |
30 | | -): State<ValueType> { |
31 | | - config = defineConfig(config, { |
32 | | - agileInstance: shared, |
33 | | - }); |
34 | | - return new State<ValueType>( |
35 | | - config.agileInstance as any, |
36 | | - initialValue, |
37 | | - removeProperties(config, ['agileInstance']) |
38 | | - ); |
39 | | -} |
40 | | - |
41 | | -// TODO 'createState' doesn't get entirely treeshaken away (React project) |
42 | | -/** |
43 | | - * Returns a newly created enhanced State. |
44 | | - * |
45 | | - * An enhanced State manages, like a normal State, a piece of Information |
46 | | - * that we need to remember globally at a later point in time. |
47 | | - * While providing a toolkit to use and mutate this piece of Information. |
48 | | - * |
49 | | - * The main difference to a normal State is however |
50 | | - * that an enhanced State provides a wider variety of inbuilt utilities (like a persist, undo, watch functionality) |
51 | | - * but requires a larger bundle size in return. |
52 | | - * |
53 | | - * You can create as many global enhanced States as you need. |
54 | | - * |
55 | | - * [Learn more..](https://agile-ts.org/docs/core/agile-instance/methods#createstate) |
56 | | - * |
57 | | - * @public |
58 | | - * @param initialValue - Initial value of the State. |
59 | | - * @param config - Configuration object |
60 | | - */ |
61 | | -export function createState<ValueType = any>( |
62 | | - initialValue: ValueType, |
63 | | - config: CreateStateConfigInterfaceWithAgile = {} |
64 | | -): EnhancedState<ValueType> { |
65 | | - config = defineConfig(config, { |
66 | | - agileInstance: shared, |
67 | | - }); |
68 | | - return new EnhancedState<ValueType>( |
69 | | - config.agileInstance as any, |
70 | | - initialValue, |
71 | | - removeProperties(config, ['agileInstance']) |
72 | | - ); |
73 | | -} |
74 | | - |
75 | | -export interface CreateStateConfigInterfaceWithAgile |
76 | | - extends CreateAgileSubInstanceInterface, |
77 | | - StateConfigInterface {} |
| 7 | +// Outsourced from here because of tree shaking issues (See: https://github.com/agile-ts/agile/issues/196) |
| 8 | +export * from './public'; |
0 commit comments