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

Commit 075735c

Browse files
committed
fixed typos
1 parent fc9266b commit 075735c

File tree

9 files changed

+70
-68
lines changed

9 files changed

+70
-68
lines changed

examples/react-native/develop/AwesomeTSProject/core/index.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
import { Agile } from '@agile-ts/core';
2-
import { Event } from '@agile-ts/event';
1+
import { createState, createComputed, createCollection } from '@agile-ts/core';
2+
import { createEvent, Event } from '@agile-ts/event';
33
import { Alert } from 'react-native';
44

5-
export const App = new Agile({
6-
logConfig: { active: true },
7-
});
8-
9-
export const MY_STATE = App.createState<string>('MyState', { key: 'my-state' }); //.persist();
10-
export const MY_STATE_2 = App.createState<string>('MyState2'); //.persist("my-state2");
11-
export const MY_STATE_3 = App.createState<number>(1); //.persist("my-state2");
5+
export const MY_STATE = createState<string>('MyState', { key: 'my-state' }); //.persist();
6+
export const MY_STATE_2 = createState<string>('MyState2'); //.persist("my-state2");
7+
export const MY_STATE_3 = createState<number>(1); //.persist("my-state2");
128

139
MY_STATE.watch('test', (value: any) => {
1410
console.log('Watch ' + value);
1511
});
1612

17-
export const MY_COMPUTED = App.createComputed<string>(() => {
13+
export const MY_COMPUTED = createComputed<string>(() => {
1814
return 'test' + MY_STATE.value + '_computed_' + MY_STATE_2.value;
1915
});
2016

@@ -23,7 +19,7 @@ interface collectionValueInterface {
2319
name: string;
2420
}
2521

26-
export const MY_COLLECTION = App.createCollection<collectionValueInterface>(
22+
export const MY_COLLECTION = createCollection<collectionValueInterface>(
2723
(collection) => ({
2824
key: 'my-collection',
2925
groups: {
@@ -43,7 +39,7 @@ MY_COLLECTION.getGroup('myGroup')?.persist({
4339

4440
console.log('Initial: myCollection ', MY_COLLECTION);
4541

46-
export const MY_EVENT = new Event<{ name: string }>(App);
42+
export const MY_EVENT = createEvent<{ name: string }>();
4743

4844
MY_EVENT.on('Test', (payload) => {
4945
Alert.alert(

examples/react/develop/class-component-ts/src/core/index.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
import { Agile, clone, Logger } from '@agile-ts/core';
2-
import { Event } from '@agile-ts/event';
1+
import {
2+
clone,
3+
createState,
4+
createComputed,
5+
createCollection,
6+
} from '@agile-ts/core';
7+
import { createEvent, Event } from '@agile-ts/event';
38

4-
export const App = new Agile({
5-
logConfig: { level: Logger.level.DEBUG, timestamp: true },
6-
waitForMount: false,
7-
});
8-
9-
export const MY_STATE = App.createState<string>('MyState'); //.persist();
10-
export const MY_STATE_2 = App.createState<string>('MyState2', {
9+
export const MY_STATE = createState<string>('MyState'); //.persist();
10+
export const MY_STATE_2 = createState<string>('MyState2', {
1111
key: 'myState2',
1212
}).persist();
1313
MY_STATE_2.onLoad(() => {
1414
console.log('On Load');
1515
});
16-
export const MY_STATE_3 = App.createState<number>(1); //.persist("my-state2");
16+
export const MY_STATE_3 = createState<number>(1); //.persist("my-state2");
1717

1818
MY_STATE.watch('test', (value: any) => {
1919
console.log('Watch ' + value);
2020
});
2121

22-
export const MY_COMPUTED = App.createComputed<string>(() => {
22+
export const MY_COMPUTED = createComputed<string>(() => {
2323
return 'test' + MY_STATE.value + '_computed_' + MY_STATE_2.value;
2424
}, []).setKey('myComputed');
2525

@@ -28,7 +28,7 @@ interface collectionValueInterface {
2828
name: string;
2929
}
3030

31-
export const MY_COLLECTION = App.createCollection<collectionValueInterface>(
31+
export const MY_COLLECTION = createCollection<collectionValueInterface>(
3232
(collection) => ({
3333
key: 'my-collection',
3434
groups: {
@@ -48,7 +48,7 @@ MY_COLLECTION.getGroup('myGroup')?.persist({
4848

4949
console.log('Initial: myCollection ', clone(MY_COLLECTION));
5050

51-
export const MY_EVENT = new Event<{ name: string }>(App, {
51+
export const MY_EVENT = createEvent<{ name: string }>({
5252
delay: 3000,
5353
key: 'myEvent',
5454
});

examples/react/develop/functional-component-ts/src/App.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ const App = (props: any) => {
4444
]);
4545
const [myGroup] = useAgile([MY_COLLECTION.getGroupWithReference('myGroup')]);
4646

47-
const selectedObjectItem = useSelector(STATE_OBJECT, (value) => {
48-
return value.age;
49-
});
47+
const stateObjectAge = useSelector<typeof STATE_OBJECT.value, number>(
48+
STATE_OBJECT,
49+
(value) => {
50+
return value.age;
51+
}
52+
);
5053

5154
const [stateObject, item2, collection2] = useProxy(
5255
[STATE_OBJECT, MY_COLLECTION.getItem('id2'), MY_COLLECTION],
@@ -56,8 +59,6 @@ const App = (props: any) => {
5659
console.log('Item1: ', item2?.name);
5760
console.log('Collection: ', collection2.slice(0, 2));
5861

59-
// const myCollection2 = useAgile(MY_COLLECTION);
60-
6162
const mySelector = useAgile(MY_COLLECTION.getSelector('mySelector'));
6263

6364
useEvent(MY_EVENT, () => {
@@ -126,6 +127,13 @@ const App = (props: any) => {
126127
}}>
127128
Change shallow name
128129
</button>
130+
<p>Age: {stateObjectAge}</p>
131+
<button
132+
onClick={() => {
133+
STATE_OBJECT.patch({ age: generateId(2) });
134+
}}>
135+
Change age
136+
</button>
129137
</div>
130138

131139
<div className={'Container'}>

examples/react/develop/functional-component-ts/src/core/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Agile, {
88
Item,
99
assignSharedAgileStorageManager,
1010
} from '@agile-ts/core';
11-
import Event from '@agile-ts/event';
11+
import { createEvent } from '@agile-ts/event';
1212
import { assignSharedAgileLoggerConfig, Logger } from '@agile-ts/logger';
1313
import { clone } from '@agile-ts/utils';
1414

@@ -114,7 +114,7 @@ export const externalCreatedItem = new Item(MY_COLLECTION, {
114114

115115
console.log('Initial: myCollection ', clone(MY_COLLECTION));
116116

117-
export const MY_EVENT = new Event<{ name: string }>(App, {
117+
export const MY_EVENT = createEvent<{ name: string }>({
118118
delay: 3000,
119119
key: 'myEvent',
120120
});

examples/react/develop/multieditor-ts/src/core/agile.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { Agile, globalBind } from '@agile-ts/core';
22

3-
const App = new Agile({
4-
logConfig: {
5-
active: true,
6-
},
7-
});
3+
const App = new Agile();
84

95
export default App;
106

examples/react/release/boxes/yarn.lock

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,20 @@
33

44

55
"@agile-ts/core@file:.yalc/@agile-ts/core":
6-
version "0.1.2"
6+
version "0.2.0-alpha.4"
77
dependencies:
88
"@agile-ts/utils" "^0.0.7"
99

10-
"@agile-ts/logger@^0.0.7":
10+
"@agile-ts/logger@file:.yalc/@agile-ts/logger":
1111
version "0.0.7"
12-
resolved "https://registry.yarnpkg.com/@agile-ts/logger/-/logger-0.0.7.tgz#9e89e8d80f80a46901a508432696860f88d5e878"
13-
integrity sha512-6N9qyooo/a7ibyl9L7HnBX0LyMlSwaEYgObYs58KzR19JGF00PX/sUFfQAVplXXsMfT/8HvLyI+4TssmyI6DdQ==
1412
dependencies:
1513
"@agile-ts/utils" "^0.0.7"
1614

17-
"@agile-ts/proxytree@^0.0.5":
15+
"@agile-ts/proxytree@file:.yalc/@agile-ts/proxytree":
1816
version "0.0.5"
19-
resolved "https://registry.yarnpkg.com/@agile-ts/proxytree/-/proxytree-0.0.5.tgz#81c40970707271822a176ee59f93b9230df6311d"
20-
integrity sha512-KODknVD30ld9xPCyt0UCf0yGcroy/0CHEncAdmTFwEvDSMipMaqFQRsAYZ0tgB4bMfFzab40aUmYTK8XDkwdHw==
2117

22-
"@agile-ts/react@^0.1.2":
23-
version "0.1.2"
24-
resolved "https://registry.yarnpkg.com/@agile-ts/react/-/react-0.1.2.tgz#d07f6b935d9322cd60d2e9e3871da554b04460af"
25-
integrity sha512-W4u2+X6KCeXPdkjit/NsMJG5nBsa7dNFaEzyfTsp5Cqbs99zLqY6dO8LUIYyhRt/+HBvEW9o64i/6Kqd59WM1Q==
18+
"@agile-ts/react@file:.yalc/@agile-ts/react":
19+
version "0.2.0-alpha.1"
2620

2721
"@agile-ts/utils@^0.0.7":
2822
version "0.0.7"

examples/react/release/stopwatch-query-url/src/core/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { createState, globalBind, shared } from '@agile-ts/core';
1+
import {
2+
createState,
3+
globalBind,
4+
createStorage,
5+
getStorageManager,
6+
} from '@agile-ts/core';
27
import queryString from 'query-string';
38

49
export type StopwatchStateType =
@@ -7,7 +12,7 @@ export type StopwatchStateType =
712
| 'initial'; // Stopwatch is reset
813

914
// Create Query Storage to store the State in the query (url)
10-
const queryUrlStorage = shared.createStorage({
15+
const queryUrlStorage = createStorage({
1116
key: 'query-url',
1217
methods: {
1318
set: (key, value) => {
@@ -30,7 +35,7 @@ const queryUrlStorage = shared.createStorage({
3035
});
3136

3237
// Register Query Storage to the shared Agile Instance and set it as default
33-
shared.registerStorage(queryUrlStorage, { default: true });
38+
getStorageManager().register(queryUrlStorage, { default: true });
3439

3540
// State to keep track of the current time of the Stopwatch
3641
const TIME = createState(

examples/vue/develop/my-project/src/core.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import { Agile, assignSharedAgileInstance, globalBind } from '@agile-ts/core';
1+
import {
2+
globalBind,
3+
createState,
4+
createComputed,
5+
createCollection,
6+
} from '@agile-ts/core';
27
import { Logger, assignSharedAgileLoggerConfig } from '@agile-ts/logger';
38
import '@agile-ts/vue';
49

510
assignSharedAgileLoggerConfig({ level: Logger.level.DEBUG });
611

7-
// Create Agile Instance
8-
export const App = new Agile({ localStorage: true });
9-
assignSharedAgileInstance(App);
10-
1112
// console.debug('hi'); // Doesn't work here idk why
1213

1314
// Create State
14-
export const MY_STATE = App.createState('World', {
15+
export const MY_STATE = createState('World', {
1516
key: 'my-state',
16-
})
17-
.computeValue((v) => {
18-
return `Hello ${v}`;
19-
});
17+
}).computeValue((v) => {
18+
return `Hello ${v}`;
19+
});
2020

21-
export const MY_COMPUTED = App.createComputed(
21+
export const MY_COMPUTED = createComputed(
2222
async () => {
2323
await new Promise((resolve) => setTimeout(resolve, 3000));
2424
return `${MY_STATE.value} Frank`;
@@ -27,7 +27,7 @@ export const MY_COMPUTED = App.createComputed(
2727
);
2828

2929
// Create Collection
30-
export const TODOS = App.createCollection({
30+
export const TODOS = createCollection({
3131
initialData: [{ id: 1, name: 'Clean Bathroom' }],
3232
selectors: [1],
3333
}).persist('todos');

packages/react/src/hooks/useValue.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,28 @@ import {
55
State,
66
defineConfig,
77
} from '@agile-ts/core';
8-
import { AgileHookConfigInterface, useAgile } from './useAgile';
9-
import { SubscribableAgileInstancesType } from './useBaseAgile';
8+
import { useAgile } from './useAgile';
9+
import {
10+
BaseAgileHookConfigInterface,
11+
SubscribableAgileInstancesType,
12+
} from './useBaseAgile';
1013

1114
export function useValue<X extends Array<SubscribableAgileInstancesType>>(
1215
deps: X | [],
13-
config?: AgileHookConfigInterface
16+
config?: BaseAgileHookConfigInterface
1417
): AgileValueHookArrayType<X>;
1518

1619
export function useValue<X extends SubscribableAgileInstancesType>(
1720
dep: X,
18-
config?: AgileHookConfigInterface
21+
config?: BaseAgileHookConfigInterface
1922
): AgileValueHookType<X>;
2023

2124
export function useValue<
2225
X extends Array<SubscribableAgileInstancesType>,
2326
Y extends SubscribableAgileInstancesType
2427
>(
2528
deps: X | Y,
26-
config: AgileHookConfigInterface = {}
29+
config: BaseAgileHookConfigInterface = {}
2730
): AgileValueHookArrayType<X> | AgileValueHookType<Y> {
2831
return useAgile(
2932
deps as any,

0 commit comments

Comments
 (0)