synapse-storage 2.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -13
- package/dist/_utils/index.js +3 -3
- package/dist/api/api.module.js +3 -3
- package/dist/api/example.js +2 -2
- package/dist/api/index.js +5 -5
- package/dist/api/utils/endpoint-headers.js +1 -1
- package/dist/api/utils/fetch-base-query.js +1 -1
- package/dist/core/index.js +2 -2
- package/dist/core/selector/index.js +1 -1
- package/dist/core/storage/adapters/base-storage.service.js +1 -1
- package/dist/core/storage/adapters/indexed-DB.service.js +2 -2
- package/dist/core/storage/adapters/indexed-DB.service.old.js +2 -2
- package/dist/core/storage/adapters/local-storage.service.js +2 -2
- package/dist/core/storage/adapters/memory-storage.service.js +2 -2
- package/dist/core/storage/index.js +9 -9
- package/dist/core/storage/middlewares/index.js +1 -1
- package/dist/core/storage/utils/cache.util.js +1 -1
- package/dist/index.js +5 -9
- package/dist/index.js.map +1 -1
- package/dist/react/hooks/index.js +2 -2
- package/dist/react/index.js +2 -2
- package/dist/react/utils/createSynapseCtx.d.ts +23 -13
- package/dist/react/utils/createSynapseCtx.d.ts.map +1 -1
- package/dist/react/utils/createSynapseCtx.js +11 -10
- package/dist/react/utils/createSynapseCtx.js.map +1 -1
- package/dist/react/utils/index.js +1 -1
- package/dist/reactive/dispatcher/index.js +2 -2
- package/dist/reactive/dispatcher/middlewares/index.js +1 -1
- package/dist/reactive/effects/effects.module.d.ts +13 -3
- package/dist/reactive/effects/effects.module.d.ts.map +1 -1
- package/dist/reactive/effects/effects.module.js +22 -8
- package/dist/reactive/effects/effects.module.js.map +1 -1
- package/dist/reactive/effects/index.js +1 -1
- package/dist/reactive/effects/utils/index.js +2 -2
- package/dist/reactive/index.js +2 -2
- package/dist/utils/createSynapse.d.ts +58 -18
- package/dist/utils/createSynapse.d.ts.map +1 -1
- package/dist/utils/createSynapse.js +4 -12
- package/dist/utils/createSynapse.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/_examples/_example5.d.ts +0 -1
- package/dist/_examples/_example5.d.ts.map +0 -1
- package/dist/_examples/_example5.js +0 -184
- package/dist/_examples/_example5.js.map +0 -1
- package/dist/_examples/_example6.d.ts +0 -1
- package/dist/_examples/_example6.d.ts.map +0 -1
- package/dist/_examples/_example6.js +0 -168
- package/dist/_examples/_example6.js.map +0 -1
- package/dist/_examples/example1.d.ts +0 -1
- package/dist/_examples/example1.d.ts.map +0 -1
- package/dist/_examples/example1.js +0 -240
- package/dist/_examples/example1.js.map +0 -1
- package/dist/_examples/example2.d.ts +0 -1
- package/dist/_examples/example2.d.ts.map +0 -1
- package/dist/_examples/example2.js +0 -81
- package/dist/_examples/example2.js.map +0 -1
- package/dist/_examples/example3.d.ts +0 -1
- package/dist/_examples/example3.d.ts.map +0 -1
- package/dist/_examples/example3.js +0 -99
- package/dist/_examples/example3.js.map +0 -1
- package/dist/_examples/example4.d.ts +0 -1
- package/dist/_examples/example4.d.ts.map +0 -1
- package/dist/_examples/example4.js +0 -172
- package/dist/_examples/example4.js.map +0 -1
- package/dist/_examples/example5.d.ts +0 -1
- package/dist/_examples/example5.d.ts.map +0 -1
- package/dist/_examples/example5.js +0 -184
- package/dist/_examples/example5.js.map +0 -1
- package/dist/_examples/example6.d.ts +0 -1
- package/dist/_examples/example6.d.ts.map +0 -1
- package/dist/_examples/example6.js +0 -168
- package/dist/_examples/example6.js.map +0 -1
- package/dist/_examples/plugins.d.ts +0 -1
- package/dist/_examples/plugins.d.ts.map +0 -1
- package/dist/_examples/plugins.js +0 -176
- package/dist/_examples/plugins.js.map +0 -1
- package/dist/_examples/pokemons/PokemonList.d.ts +0 -5
- package/dist/_examples/pokemons/PokemonList.d.ts.map +0 -1
- package/dist/_examples/pokemons/PokemonList.js +0 -166
- package/dist/_examples/pokemons/PokemonList.js.map +0 -1
- package/dist/_examples/pokemons/api.d.ts +0 -8
- package/dist/_examples/pokemons/api.d.ts.map +0 -1
- package/dist/_examples/pokemons/api.js +0 -45
- package/dist/_examples/pokemons/api.js.map +0 -1
- package/dist/_examples/pokemons/app.config.d.ts +0 -15
- package/dist/_examples/pokemons/app.config.d.ts.map +0 -1
- package/dist/_examples/pokemons/app.config.js +0 -15
- package/dist/_examples/pokemons/app.config.js.map +0 -1
- package/dist/_examples/pokemons/dispatchers/pokemon.dispatcher.d.ts +0 -9
- package/dist/_examples/pokemons/dispatchers/pokemon.dispatcher.d.ts.map +0 -1
- package/dist/_examples/pokemons/dispatchers/pokemon.dispatcher.js +0 -122
- package/dist/_examples/pokemons/dispatchers/pokemon.dispatcher.js.map +0 -1
- package/dist/_examples/pokemons/effects/pokemon.effects.d.ts +0 -16
- package/dist/_examples/pokemons/effects/pokemon.effects.d.ts.map +0 -1
- package/dist/_examples/pokemons/effects/pokemon.effects.js +0 -39
- package/dist/_examples/pokemons/effects/pokemon.effects.js.map +0 -1
- package/dist/_examples/pokemons/middlewares/pokenon.middlewares.d.ts +0 -4
- package/dist/_examples/pokemons/middlewares/pokenon.middlewares.d.ts.map +0 -1
- package/dist/_examples/pokemons/middlewares/pokenon.middlewares.js +0 -27
- package/dist/_examples/pokemons/middlewares/pokenon.middlewares.js.map +0 -1
- package/dist/_examples/pokemons/pokemon.dispatcher.d.ts +0 -9
- package/dist/_examples/pokemons/pokemon.dispatcher.d.ts.map +0 -1
- package/dist/_examples/pokemons/pokemon.dispatcher.js +0 -122
- package/dist/_examples/pokemons/pokemon.dispatcher.js.map +0 -1
- package/dist/_examples/pokemons/pokemon.effects.d.ts +0 -5
- package/dist/_examples/pokemons/pokemon.effects.d.ts.map +0 -1
- package/dist/_examples/pokemons/pokemon.effects.js +0 -39
- package/dist/_examples/pokemons/pokemon.effects.js.map +0 -1
- package/dist/_examples/pokemons/pokemon.selectors.d.ts +0 -5
- package/dist/_examples/pokemons/pokemon.selectors.d.ts.map +0 -1
- package/dist/_examples/pokemons/pokemon.selectors.js +0 -10
- package/dist/_examples/pokemons/pokemon.selectors.js.map +0 -1
- package/dist/_examples/pokemons/pokemon.storage.d.ts +0 -3
- package/dist/_examples/pokemons/pokemon.storage.d.ts.map +0 -1
- package/dist/_examples/pokemons/pokemon.storage.js +0 -14
- package/dist/_examples/pokemons/pokemon.storage.js.map +0 -1
- package/dist/_examples/pokemons/pokemon1.selectors.d.ts +0 -5
- package/dist/_examples/pokemons/pokemon1.selectors.d.ts.map +0 -1
- package/dist/_examples/pokemons/pokemon1.selectors.js +0 -8
- package/dist/_examples/pokemons/pokemon1.selectors.js.map +0 -1
- package/dist/_examples/pokemons/pokenon.middlewares.d.ts +0 -4
- package/dist/_examples/pokemons/pokenon.middlewares.d.ts.map +0 -1
- package/dist/_examples/pokemons/pokenon.middlewares.js +0 -27
- package/dist/_examples/pokemons/pokenon.middlewares.js.map +0 -1
- package/dist/_examples/pokemons/selectors/pokemon.selectors.d.ts +0 -5
- package/dist/_examples/pokemons/selectors/pokemon.selectors.d.ts.map +0 -1
- package/dist/_examples/pokemons/selectors/pokemon.selectors.js +0 -10
- package/dist/_examples/pokemons/selectors/pokemon.selectors.js.map +0 -1
- package/dist/_examples/pokemons/selectors/pokemon1.selectors.d.ts +0 -5
- package/dist/_examples/pokemons/selectors/pokemon1.selectors.d.ts.map +0 -1
- package/dist/_examples/pokemons/selectors/pokemon1.selectors.js +0 -8
- package/dist/_examples/pokemons/selectors/pokemon1.selectors.js.map +0 -1
- package/dist/_examples/pokemons/storages/pokemon.storage.d.ts +0 -3
- package/dist/_examples/pokemons/storages/pokemon.storage.d.ts.map +0 -1
- package/dist/_examples/pokemons/storages/pokemon.storage.js +0 -14
- package/dist/_examples/pokemons/storages/pokemon.storage.js.map +0 -1
- package/dist/_examples/pokemons/store.d.ts +0 -1
- package/dist/_examples/pokemons/store.d.ts.map +0 -1
- package/dist/_examples/pokemons/store.js +0 -2
- package/dist/_examples/pokemons/store.js.map +0 -1
- package/dist/_examples/pokemons/store1.d.ts +0 -23
- package/dist/_examples/pokemons/store1.d.ts.map +0 -1
- package/dist/_examples/pokemons/store1.js +0 -35
- package/dist/_examples/pokemons/store1.js.map +0 -1
- package/dist/_examples/pokemons/store2.d.ts +0 -23
- package/dist/_examples/pokemons/store2.d.ts.map +0 -1
- package/dist/_examples/pokemons/store2.js +0 -34
- package/dist/_examples/pokemons/store2.js.map +0 -1
- package/dist/_examples/pokemons/types.d.ts +0 -26
- package/dist/_examples/pokemons/types.d.ts.map +0 -1
- package/dist/_examples/pokemons/types.js +0 -2
- package/dist/_examples/pokemons/types.js.map +0 -1
- package/dist/core/storage/adapters/idb.d.ts +0 -52
- package/dist/core/storage/adapters/idb.d.ts.map +0 -1
- package/dist/core/storage/adapters/idb.js +0 -528
- package/dist/core/storage/adapters/idb.js.map +0 -1
- package/dist/core/storage/adapters/indexed-DB.service1.d.ts +0 -38
- package/dist/core/storage/adapters/indexed-DB.service1.d.ts.map +0 -1
- package/dist/core/storage/adapters/indexed-DB.service1.js +0 -318
- package/dist/core/storage/adapters/indexed-DB.service1.js.map +0 -1
- package/dist/core/storage/adapters/indexed-DB.service2.d.ts +0 -61
- package/dist/core/storage/adapters/indexed-DB.service2.d.ts.map +0 -1
- package/dist/core/storage/adapters/indexed-DB.service2.js +0 -596
- package/dist/core/storage/adapters/indexed-DB.service2.js.map +0 -1
- package/dist/core/storage/factory/createSynapseStorage.factory.d.ts +0 -1
- package/dist/core/storage/factory/createSynapseStorage.factory.d.ts.map +0 -1
- package/dist/core/storage/factory/createSynapseStorage.factory.js +0 -2
- package/dist/core/storage/factory/createSynapseStorage.factory.js.map +0 -1
- package/dist/core/storage/factory/index.d.ts +0 -2
- package/dist/core/storage/factory/index.d.ts.map +0 -1
- package/dist/core/storage/factory/index.js +0 -2
- package/dist/core/storage/factory/index.js.map +0 -1
- package/dist/examples/_example5.d.ts +0 -1
- package/dist/examples/_example5.d.ts.map +0 -1
- package/dist/examples/_example5.js +0 -184
- package/dist/examples/_example5.js.map +0 -1
- package/dist/examples/_example6.d.ts +0 -1
- package/dist/examples/_example6.d.ts.map +0 -1
- package/dist/examples/_example6.js +0 -168
- package/dist/examples/_example6.js.map +0 -1
- package/dist/examples/plugins.d.ts +0 -1
- package/dist/examples/plugins.d.ts.map +0 -1
- package/dist/examples/plugins.js +0 -176
- package/dist/examples/plugins.js.map +0 -1
- package/dist/examples/pokemons/PokemonList.d.ts +0 -2
- package/dist/examples/pokemons/PokemonList.d.ts.map +0 -1
- package/dist/examples/pokemons/PokemonList.js +0 -110
- package/dist/examples/pokemons/PokemonList.js.map +0 -1
- package/dist/examples/pokemons/api.d.ts +0 -22
- package/dist/examples/pokemons/api.d.ts.map +0 -1
- package/dist/examples/pokemons/api.js +0 -43
- package/dist/examples/pokemons/api.js.map +0 -1
- package/dist/examples/pokemons/app.config.d.ts +0 -15
- package/dist/examples/pokemons/app.config.d.ts.map +0 -1
- package/dist/examples/pokemons/app.config.js +0 -15
- package/dist/examples/pokemons/app.config.js.map +0 -1
- package/dist/examples/pokemons/dispatchers/pokemon.dispatcher.js +0 -128
- package/dist/examples/pokemons/dispatchers/pokemon.dispatcher.js.map +0 -1
- package/dist/examples/pokemons/effects/pokemon.effects.d.ts +0 -16
- package/dist/examples/pokemons/effects/pokemon.effects.d.ts.map +0 -1
- package/dist/examples/pokemons/effects/pokemon.effects.js +0 -51
- package/dist/examples/pokemons/effects/pokemon.effects.js.map +0 -1
- package/dist/examples/pokemons/middlewares/pokenon.middlewares.d.ts +0 -4
- package/dist/examples/pokemons/middlewares/pokenon.middlewares.d.ts.map +0 -1
- package/dist/examples/pokemons/middlewares/pokenon.middlewares.js +0 -28
- package/dist/examples/pokemons/middlewares/pokenon.middlewares.js.map +0 -1
- package/dist/examples/pokemons/selectors/pokemon.selectors.d.ts +0 -13
- package/dist/examples/pokemons/selectors/pokemon.selectors.d.ts.map +0 -1
- package/dist/examples/pokemons/selectors/pokemon.selectors.js +0 -7
- package/dist/examples/pokemons/selectors/pokemon.selectors.js.map +0 -1
- package/dist/examples/pokemons/storages/pokemon.storage.d.ts +0 -5
- package/dist/examples/pokemons/storages/pokemon.storage.d.ts.map +0 -1
- package/dist/examples/pokemons/storages/pokemon.storage.js +0 -13
- package/dist/examples/pokemons/storages/pokemon.storage.js.map +0 -1
- package/dist/examples/pokemons/store.d.ts +0 -35
- package/dist/examples/pokemons/store.d.ts.map +0 -1
- package/dist/examples/pokemons/store.js +0 -21
- package/dist/examples/pokemons/store.js.map +0 -1
- package/dist/examples/pokemons/types.d.ts +0 -26
- package/dist/examples/pokemons/types.d.ts.map +0 -1
- package/dist/examples/pokemons/types.js +0 -2
- package/dist/examples/pokemons/types.js.map +0 -1
- package/dist/react/utils/createSynapse.d.ts +0 -47
- package/dist/react/utils/createSynapse.d.ts.map +0 -1
- package/dist/react/utils/createSynapse.js +0 -83
- package/dist/react/utils/createSynapse.js.map +0 -1
- package/dist/react/utils/createSynapseContext.d.ts +0 -29
- package/dist/react/utils/createSynapseContext.d.ts.map +0 -1
- package/dist/react/utils/createSynapseContext.js +0 -112
- package/dist/react/utils/createSynapseContext.js.map +0 -1
- package/dist/utils/chunk.util.d.ts +0 -8
- package/dist/utils/chunk.util.d.ts.map +0 -1
- package/dist/utils/chunk.util.js +0 -21
- package/dist/utils/chunk.util.js.map +0 -1
- package/dist/utils/deepMerge.util.d.ts +0 -2
- package/dist/utils/deepMerge.util.d.ts.map +0 -1
- package/dist/utils/deepMerge.util.js +0 -16
- package/dist/utils/deepMerge.util.js.map +0 -1
- package/dist/utils/flatMap.util.d.ts +0 -10
- package/dist/utils/flatMap.util.d.ts.map +0 -1
- package/dist/utils/flatMap.util.js +0 -23
- package/dist/utils/flatMap.util.js.map +0 -1
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
import { distinctUntilChanged, map } from 'rxjs/operators';
|
|
4
|
-
import { useSelector, useStorageSubscribe } from 'synapse/react';
|
|
5
|
-
import { pokemonActions, pokemonSelectors, pokemonState$, pokemonStorage } from './store1';
|
|
6
|
-
/**
|
|
7
|
-
* Упрощенный React-компонент для работы с одним покемоном
|
|
8
|
-
*/
|
|
9
|
-
export function SimplePokemonViewer() {
|
|
10
|
-
const [state, setState] = useState({
|
|
11
|
-
currentPokemon: null,
|
|
12
|
-
loading: true,
|
|
13
|
-
error: null,
|
|
14
|
-
currentId: 1,
|
|
15
|
-
});
|
|
16
|
-
const d = useSelector(pokemonSelectors.val1);
|
|
17
|
-
const d1 = useStorageSubscribe(pokemonStorage, (s) => 1);
|
|
18
|
-
// console.log('pokemonSelectors useSelector', d)
|
|
19
|
-
console.log('d1', d1);
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
pokemonSelectors.val1.select().then((val) => {
|
|
22
|
-
// console.log('pokemonSelectors select', val)
|
|
23
|
-
});
|
|
24
|
-
const ddwe = pokemonStorage.subscribe((s) => s.currentPokemon, () => {
|
|
25
|
-
});
|
|
26
|
-
}, []);
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
pokemonSelectors.val1.subscribe({
|
|
29
|
-
notify: (s) => {
|
|
30
|
-
// console.log('pokemonSelectors subscribe', s)
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
}, []);
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const subscription = pokemonState$.pipe(map((state) => state.currentId), distinctUntilChanged()).subscribe((state) => {
|
|
36
|
-
// console.log('Текущее состояние REACTIVE:', state)
|
|
37
|
-
});
|
|
38
|
-
return () => {
|
|
39
|
-
subscription.unsubscribe();
|
|
40
|
-
};
|
|
41
|
-
}, []);
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
// Подписываемся на изменения состояния напрямую из хранилища
|
|
44
|
-
const unsubscribe = pokemonStorage.subscribeToAll((event) => {
|
|
45
|
-
// Обновляем состояние при изменении
|
|
46
|
-
pokemonStorage.getState().then((state) => {
|
|
47
|
-
// console.log('Текущее состояние ОБЫЧНОЕ:', state)
|
|
48
|
-
if (state)
|
|
49
|
-
setState(state);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
// Инициируем загрузку первого покемона через действия
|
|
53
|
-
pokemonActions.loadPokemon(1);
|
|
54
|
-
// Отписываемся при размонтировании
|
|
55
|
-
return () => unsubscribe();
|
|
56
|
-
}, []);
|
|
57
|
-
// Обработчики действий
|
|
58
|
-
const handleNext = () => {
|
|
59
|
-
pokemonActions.next().then((result) => {
|
|
60
|
-
// console.log('Результат:', result) // Покажет { id: число }
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
const handlePrev = () => {
|
|
64
|
-
pokemonActions.prev();
|
|
65
|
-
};
|
|
66
|
-
const handleLoadById = (id) => {
|
|
67
|
-
if (id >= 1 && id <= 151) {
|
|
68
|
-
pokemonActions.loadPokemon(id).then((result) => {
|
|
69
|
-
// console.log('Результат:', result) // Покажет { id: число }
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
// Стили
|
|
74
|
-
const styles = {
|
|
75
|
-
container: {
|
|
76
|
-
maxWidth: '600px',
|
|
77
|
-
margin: '0 auto',
|
|
78
|
-
padding: '20px',
|
|
79
|
-
fontFamily: 'Arial, sans-serif',
|
|
80
|
-
textAlign: 'center',
|
|
81
|
-
},
|
|
82
|
-
title: {
|
|
83
|
-
fontSize: '24px',
|
|
84
|
-
fontWeight: 'bold',
|
|
85
|
-
marginBottom: '20px',
|
|
86
|
-
},
|
|
87
|
-
card: {
|
|
88
|
-
border: '1px solid #ddd',
|
|
89
|
-
borderRadius: '8px',
|
|
90
|
-
padding: '20px',
|
|
91
|
-
margin: '20px 0',
|
|
92
|
-
background: 'white',
|
|
93
|
-
boxShadow: '0 2px 4px rgba(0,0,0,0.1)',
|
|
94
|
-
},
|
|
95
|
-
pokemonName: {
|
|
96
|
-
fontSize: '20px',
|
|
97
|
-
fontWeight: 'bold',
|
|
98
|
-
textTransform: 'capitalize',
|
|
99
|
-
marginTop: '10px',
|
|
100
|
-
},
|
|
101
|
-
pokemonImage: {
|
|
102
|
-
width: '180px',
|
|
103
|
-
height: '180px',
|
|
104
|
-
},
|
|
105
|
-
typeBadge: {
|
|
106
|
-
display: 'inline-block',
|
|
107
|
-
padding: '4px 8px',
|
|
108
|
-
margin: '4px',
|
|
109
|
-
borderRadius: '16px',
|
|
110
|
-
fontSize: '12px',
|
|
111
|
-
background: '#eee',
|
|
112
|
-
},
|
|
113
|
-
stats: {
|
|
114
|
-
margin: '15px 0',
|
|
115
|
-
textAlign: 'left',
|
|
116
|
-
},
|
|
117
|
-
controls: {
|
|
118
|
-
display: 'flex',
|
|
119
|
-
justifyContent: 'space-between',
|
|
120
|
-
alignItems: 'center',
|
|
121
|
-
margin: '20px 0',
|
|
122
|
-
},
|
|
123
|
-
button: {
|
|
124
|
-
padding: '10px 20px',
|
|
125
|
-
background: '#0077cc',
|
|
126
|
-
color: 'white',
|
|
127
|
-
border: 'none',
|
|
128
|
-
borderRadius: '4px',
|
|
129
|
-
cursor: 'pointer',
|
|
130
|
-
fontSize: '16px',
|
|
131
|
-
},
|
|
132
|
-
input: {
|
|
133
|
-
padding: '10px',
|
|
134
|
-
fontSize: '16px',
|
|
135
|
-
borderRadius: '4px',
|
|
136
|
-
border: '1px solid #ddd',
|
|
137
|
-
width: '60px',
|
|
138
|
-
textAlign: 'center',
|
|
139
|
-
},
|
|
140
|
-
loader: {
|
|
141
|
-
padding: '40px',
|
|
142
|
-
fontSize: '18px',
|
|
143
|
-
},
|
|
144
|
-
error: {
|
|
145
|
-
padding: '16px',
|
|
146
|
-
background: '#ffebee',
|
|
147
|
-
color: '#c62828',
|
|
148
|
-
borderRadius: '4px',
|
|
149
|
-
margin: '20px 0',
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
// Форма ввода ID
|
|
153
|
-
function IdInput() {
|
|
154
|
-
const [inputId, setInputId] = useState('');
|
|
155
|
-
const handleSubmit = (e) => {
|
|
156
|
-
e.preventDefault();
|
|
157
|
-
const id = parseInt(inputId, 10);
|
|
158
|
-
if (!isNaN(id)) {
|
|
159
|
-
handleLoadById(id);
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
return (_jsxs("form", { onSubmit: handleSubmit, style: { marginTop: '20px' }, children: [_jsxs("label", { children: ["Go to Pok\u00E9mon #:", _jsx("input", { type: "number", min: "1", max: "151", value: inputId, onChange: (e) => setInputId(e.target.value), style: styles.input })] }), _jsx("button", { type: "submit", style: { ...styles.button, marginLeft: '10px' }, children: "Go" })] }));
|
|
163
|
-
}
|
|
164
|
-
return (_jsxs("div", { style: styles.container, children: [_jsx("h1", { style: styles.title, children: "Pok\u00E9mon Viewer" }), _jsxs("div", { style: styles.controls, children: [_jsx("button", { style: styles.button, onClick: handlePrev, children: "Previous" }), _jsxs("div", { children: ["Pok\u00E9mon #", state.currentId] }), _jsx("button", { style: styles.button, onClick: handleNext, children: "Next" })] }), state.error && (_jsx("div", { style: styles.error, children: _jsxs("p", { children: ["Error:", state.error] }) })), state.loading ? (_jsx("div", { style: styles.loader, children: _jsx("p", { children: "Loading Pok\u00E9mon..." }) })) : state.currentPokemon ? (_jsxs("div", { style: styles.card, children: [_jsx("img", { src: state.currentPokemon.sprites.other?.['official-artwork']?.front_default || state.currentPokemon.sprites.front_default, alt: state.currentPokemon.name, style: styles.pokemonImage }), _jsx("h2", { style: styles.pokemonName, children: state.currentPokemon.name }), _jsx("div", { children: state.currentPokemon.types.map(({ type }) => (_jsx("span", { style: styles.typeBadge, children: type.name }, type.name))) }), _jsxs("div", { style: styles.stats, children: [_jsxs("p", { children: [_jsx("strong", { children: "Height:" }), ' ', state.currentPokemon.height / 10, ' ', "m"] }), _jsxs("p", { children: [_jsx("strong", { children: "Weight:" }), ' ', state.currentPokemon.weight / 10, ' ', "kg"] })] })] })) : null, _jsx(IdInput, {})] }));
|
|
165
|
-
}
|
|
166
|
-
//# sourceMapping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KAAK,EAAE,MAAM,CAAC,WAAW,YAAG,KAAK,CAAC,cAAc,CAAC,IAAI,GAAM,EAE/D,wBACG,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAC5C,eAAsB,KAAK,EAAE,MAAM,CAAC,SAAS,YAC1C,IAAI,CAAC,IAAI,IADD,IAAI,CAAC,IAAI,CAEb,CACR,CAAC,GACE,EAEN,eAAK,KAAK,EAAE,MAAM,CAAC,KAAK,aACtB,wBACE,uCAAwB,EACvB,GAAG,EACH,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,EAAE,EAChC,GAAG,SAEF,EACJ,wBACE,uCAAwB,EACvB,GAAG,EACH,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,EAAE,EAChC,GAAG,UAEF,IACA,IACF,CACP,CAAC,CAAC,CAAC,IAAI,EAER,KAAC,OAAO,KAAG,IACP,CACP,CAAA;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/_examples/pokemons/api.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,eAAO,MAAM,GAAG,KAoCd,CAAA;AAEF,eAAO,MAAM,UAAU,KAAmB,CAAA;AAK1C,eAAO,MAAM,gBAAgB,KAA4B,CAAA"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { ApiClient, ResponseFormat } from 'synapse/api';
|
|
2
|
-
export const api = new ApiClient({
|
|
3
|
-
storageType: 'indexedDB',
|
|
4
|
-
storageOptions: {
|
|
5
|
-
name: 'pokemon-api-storage',
|
|
6
|
-
dbName: 'pokemon-api-cache',
|
|
7
|
-
storeName: 'requests',
|
|
8
|
-
dbVersion: 1,
|
|
9
|
-
},
|
|
10
|
-
// Или boolean или объект с настройками
|
|
11
|
-
cache: {
|
|
12
|
-
// Время жизни кэша в миллисекундах
|
|
13
|
-
ttl: 5 * 60 * 1000, // 5 минут
|
|
14
|
-
// Инвалидировать кэш при ошибке
|
|
15
|
-
invalidateOnError: true,
|
|
16
|
-
cleanup: {
|
|
17
|
-
// Включить периодическую очистку
|
|
18
|
-
enabled: true,
|
|
19
|
-
// Интервал очистки в миллисекундах
|
|
20
|
-
interval: 10 * 60 * 1000, // 10 минут
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
baseQuery: {
|
|
24
|
-
baseUrl: 'https://pokeapi.co/api/v2',
|
|
25
|
-
timeout: 10000,
|
|
26
|
-
credentials: 'same-origin',
|
|
27
|
-
},
|
|
28
|
-
endpoints: async (create) => ({
|
|
29
|
-
fetchPokemonById: create({
|
|
30
|
-
request: (params) => ({
|
|
31
|
-
path: `/pokemon/${params.id}`,
|
|
32
|
-
method: 'GET',
|
|
33
|
-
responseFormat: ResponseFormat.Json,
|
|
34
|
-
}),
|
|
35
|
-
tags: ['pokemon-details'],
|
|
36
|
-
}),
|
|
37
|
-
}),
|
|
38
|
-
});
|
|
39
|
-
// Инициализация
|
|
40
|
-
export const pokemonApi = await api.init();
|
|
41
|
-
// Демонтирование
|
|
42
|
-
// await pokemonApi.destroy()
|
|
43
|
-
// Получение эндпоинтов
|
|
44
|
-
export const pokemonEndpoints = pokemonApi.getEndpoints();
|
|
45
|
-
//# sourceMappingURL=api.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/_examples/pokemons/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAQvD,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC;IAC/B,WAAW,EAAE,WAAW;IACxB,cAAc,EAAE;QACd,IAAI,EAAE,qBAAqB;QAC3B,MAAM,EAAE,mBAAmB;QAC3B,SAAS,EAAE,UAAU;QACrB,SAAS,EAAE,CAAC;KACb;IACD,uCAAuC;IACvC,KAAK,EAAE;QACL,mCAAmC;QACnC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,UAAU;QAC9B,iCAAiC;QACjC,iBAAiB,EAAE,IAAI;QACvB,OAAO,EAAE;YACP,iCAAiC;YACjC,OAAO,EAAE,IAAI;YACb,mCAAmC;YACnC,QAAQ,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,WAAW;SACtC;KACF;IACD,SAAS,EAAE;QACT,OAAO,EAAE,2BAA2B;QACpC,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,aAAa;KAC3B;IACD,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QAC5B,gBAAgB,EAAE,MAAM,CAA0B;YAChD,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;gBACpB,IAAI,EAAE,YAAY,MAAM,CAAC,EAAE,EAAE;gBAC7B,MAAM,EAAE,KAAK;gBACb,cAAc,EAAE,cAAc,CAAC,IAAI;aACpC,CAAC;YACF,IAAI,EAAE,CAAC,iBAAiB,CAAC;SAC1B,CAAC;KACH,CAAC;CACH,CAAC,CAAA;AACF,gBAAgB;AAChB,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;AAC1C,iBAAiB;AACjB,6BAA6B;AAE7B,uBAAuB;AACvB,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC,YAAY,EAAE,CAAA"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface AppConfig {
|
|
2
|
-
apiBaseUrl: string;
|
|
3
|
-
apiKey: string;
|
|
4
|
-
requestTimeoutMs: number;
|
|
5
|
-
features: {
|
|
6
|
-
enableNotifications: boolean;
|
|
7
|
-
enableCache: boolean;
|
|
8
|
-
};
|
|
9
|
-
themeSettings: {
|
|
10
|
-
primaryColor: string;
|
|
11
|
-
secondaryColor: string;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export declare const appConfig: AppConfig;
|
|
15
|
-
//# sourceMappingURL=app.config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.config.d.ts","sourceRoot":"","sources":["../../../src/_examples/pokemons/app.config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,EAAE;QACR,mBAAmB,EAAE,OAAO,CAAA;QAC5B,WAAW,EAAE,OAAO,CAAA;KACrB,CAAA;IACD,aAAa,EAAE;QACb,YAAY,EAAE,MAAM,CAAA;QACpB,cAAc,EAAE,MAAM,CAAA;KACvB,CAAA;CACF;AAED,eAAO,MAAM,SAAS,EAAE,SAYvB,CAAA"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Просто условный объект с конфигурацией, которую можно использовать в эффектах
|
|
2
|
-
export const appConfig = {
|
|
3
|
-
apiBaseUrl: 'https://pokeapi.co/api/v2',
|
|
4
|
-
apiKey: 'your-api-key-here',
|
|
5
|
-
requestTimeoutMs: 5000,
|
|
6
|
-
features: {
|
|
7
|
-
enableNotifications: true,
|
|
8
|
-
enableCache: true,
|
|
9
|
-
},
|
|
10
|
-
themeSettings: {
|
|
11
|
-
primaryColor: '#FF0000', // Pokemon Red!
|
|
12
|
-
secondaryColor: '#FFFFFF',
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=app.config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.config.js","sourceRoot":"","sources":["../../../src/_examples/pokemons/app.config.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAiBhF,MAAM,CAAC,MAAM,SAAS,GAAc;IAClC,UAAU,EAAE,2BAA2B;IACvC,MAAM,EAAE,mBAAmB;IAC3B,gBAAgB,EAAE,IAAI;IACtB,QAAQ,EAAE;QACR,mBAAmB,EAAE,IAAI;QACzB,WAAW,EAAE,IAAI;KAClB;IACD,aAAa,EAAE;QACb,YAAY,EAAE,SAAS,EAAE,eAAe;QACxC,cAAc,EAAE,SAAS;KAC1B;CACF,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { PokemonStorage } from '../storages/pokemon.storage';
|
|
2
|
-
export interface AlertPayload {
|
|
3
|
-
message: string;
|
|
4
|
-
type: 'info' | 'warning' | 'error' | 'success';
|
|
5
|
-
duration?: number;
|
|
6
|
-
}
|
|
7
|
-
export declare function createPokemonDispatcher(storage: PokemonStorage): any;
|
|
8
|
-
export type PokemonDispatcher = ReturnType<typeof createPokemonDispatcher>;
|
|
9
|
-
//# sourceMappingURL=pokemon.dispatcher.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pokemon.dispatcher.d.ts","sourceRoot":"","sources":["../../../../src/_examples/pokemons/dispatchers/pokemon.dispatcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAK5D,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAGD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,cAAc,OAmI9D;AAGD,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { createDispatcher, loggerDispatcherMiddleware } from 'synapse/reactive';
|
|
2
|
-
import { createPokemonAlertMiddleware } from '../middlewares/pokenon.middlewares';
|
|
3
|
-
// Функция для создания диспетчера
|
|
4
|
-
export function createPokemonDispatcher(storage) {
|
|
5
|
-
// Создаем логгер middleware
|
|
6
|
-
const loggerMiddleware = loggerDispatcherMiddleware({
|
|
7
|
-
collapsed: true, // Сворачиваем группы в консоли для компактности
|
|
8
|
-
colors: {
|
|
9
|
-
title: '#3498db', // Кастомный синий цвет для заголовка
|
|
10
|
-
},
|
|
11
|
-
duration: true,
|
|
12
|
-
diff: true,
|
|
13
|
-
showFullState: true,
|
|
14
|
-
});
|
|
15
|
-
const alertM = createPokemonAlertMiddleware();
|
|
16
|
-
return createDispatcher({
|
|
17
|
-
storage,
|
|
18
|
-
middlewares: [loggerMiddleware, alertM],
|
|
19
|
-
}, (storage, { createWatcher, createAction }) => ({
|
|
20
|
-
// Добавляем watcher для отслеживания текущего ID
|
|
21
|
-
watchCurrentId: createWatcher({
|
|
22
|
-
type: 'pokemon/currentIdChanged',
|
|
23
|
-
selector: (state) => state.currentId,
|
|
24
|
-
shouldTrigger: (prev, curr) => prev !== curr,
|
|
25
|
-
meta: {
|
|
26
|
-
description: 'Следит за изменениями ID текущего покемона',
|
|
27
|
-
},
|
|
28
|
-
}),
|
|
29
|
-
// Watcher для отслеживания состояния загрузки
|
|
30
|
-
watchLoadingState: createWatcher({
|
|
31
|
-
type: 'pokemon/loadingStateChanged',
|
|
32
|
-
selector: (state) => state.loading,
|
|
33
|
-
}),
|
|
34
|
-
// Загрузка покемона по ID
|
|
35
|
-
loadPokemon: createAction({
|
|
36
|
-
type: 'pokemon/loadPokemonIdl',
|
|
37
|
-
action: async (id) => ({ id }),
|
|
38
|
-
}),
|
|
39
|
-
loadPokemonRequest: createAction({
|
|
40
|
-
type: 'pokemon/loadPokemonRequest',
|
|
41
|
-
action: async (id) => {
|
|
42
|
-
await storage.update((state) => {
|
|
43
|
-
state.loading = true;
|
|
44
|
-
state.error = null;
|
|
45
|
-
state.currentId = id;
|
|
46
|
-
});
|
|
47
|
-
return { id };
|
|
48
|
-
},
|
|
49
|
-
}),
|
|
50
|
-
// Успешное получение данных
|
|
51
|
-
success: createAction({
|
|
52
|
-
type: 'pokemon/success',
|
|
53
|
-
action: async ({ data }) => {
|
|
54
|
-
await storage.update((state) => {
|
|
55
|
-
state.currentPokemon = data;
|
|
56
|
-
state.loading = false;
|
|
57
|
-
state.error = null;
|
|
58
|
-
});
|
|
59
|
-
// Возвращаем данные покемона как payload
|
|
60
|
-
return { data };
|
|
61
|
-
},
|
|
62
|
-
}),
|
|
63
|
-
// Ошибка при получении данных
|
|
64
|
-
failure: createAction({
|
|
65
|
-
type: 'pokemon/failure',
|
|
66
|
-
action: async (err) => {
|
|
67
|
-
const errorMessage = err instanceof Error ? err.message : 'Unknown error';
|
|
68
|
-
await storage.update((state) => {
|
|
69
|
-
state.loading = false;
|
|
70
|
-
state.error = errorMessage;
|
|
71
|
-
});
|
|
72
|
-
// Возвращаем ошибку как payload
|
|
73
|
-
return { err };
|
|
74
|
-
},
|
|
75
|
-
}),
|
|
76
|
-
// Перейти к следующему покемону
|
|
77
|
-
next: createAction({
|
|
78
|
-
type: 'pokemon/next',
|
|
79
|
-
action: async () => {
|
|
80
|
-
let newId = 1;
|
|
81
|
-
await storage.update((state) => {
|
|
82
|
-
newId = state.currentId + 1;
|
|
83
|
-
if (newId > 151)
|
|
84
|
-
newId = 1; // Ограничиваем первым поколением (1-151)
|
|
85
|
-
state.currentId = newId;
|
|
86
|
-
});
|
|
87
|
-
return { id: newId };
|
|
88
|
-
},
|
|
89
|
-
}),
|
|
90
|
-
// Перейти к предыдущему покемону
|
|
91
|
-
prev: createAction({
|
|
92
|
-
type: 'pokemon/prev',
|
|
93
|
-
action: async () => {
|
|
94
|
-
let newId = 1;
|
|
95
|
-
await storage.update((state) => {
|
|
96
|
-
newId = state.currentId - 1;
|
|
97
|
-
if (newId < 1)
|
|
98
|
-
newId = 151; // Ограничиваем первым поколением (1-151)
|
|
99
|
-
state.currentId = newId;
|
|
100
|
-
});
|
|
101
|
-
console.log(`Action: Previous pokemon (ID ${newId})`);
|
|
102
|
-
// Возвращаем новый id как payload
|
|
103
|
-
return { id: newId };
|
|
104
|
-
},
|
|
105
|
-
}),
|
|
106
|
-
showAlert: createAction({
|
|
107
|
-
type: 'pokemon/showAlert',
|
|
108
|
-
action: async (payload) => {
|
|
109
|
-
// Используем глобальный alert для демонстрации
|
|
110
|
-
alert(payload.message);
|
|
111
|
-
// Здесь можно также обновить состояние для отображения alert в UI
|
|
112
|
-
// например, добавить запись в массив alerts в state
|
|
113
|
-
},
|
|
114
|
-
meta: {
|
|
115
|
-
description: 'Показывает оповещение пользователю',
|
|
116
|
-
},
|
|
117
|
-
}),
|
|
118
|
-
}));
|
|
119
|
-
// .use(logger)
|
|
120
|
-
// .use(alertM)
|
|
121
|
-
}
|
|
122
|
-
//# sourceMappingURL=pokemon.dispatcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pokemon.dispatcher.js","sourceRoot":"","sources":["../../../../src/_examples/pokemons/dispatchers/pokemon.dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAE/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAA;AAUjF,kCAAkC;AAClC,MAAM,UAAU,uBAAuB,CAAC,OAAuB;IAC7D,4BAA4B;IAC5B,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;QAClD,SAAS,EAAE,IAAI,EAAE,gDAAgD;QACjE,MAAM,EAAE;YACN,KAAK,EAAE,SAAS,EAAE,qCAAqC;SACxD;QACD,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,IAAI;QACV,aAAa,EAAE,IAAI;KACpB,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,4BAA4B,EAAE,CAAA;IAE7C,OAAO,gBAAgB,CAAC;QACtB,OAAO;QACP,WAAW,EAAE,CAAC,gBAAgB,EAAE,MAAM,CAAC;KACxC,EAAE,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC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pB,MAAM,EAAE,KAAK,IAAI,EAAE;gBACjB,IAAI,KAAK,GAAG,CAAC,CAAA;gBAEb,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;oBAC7B,KAAK,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,CAAA;oBAC3B,IAAI,KAAK,GAAG,CAAC;wBAAE,KAAK,GAAG,GAAG,CAAA,CAAC,yCAAyC;oBACpE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAA;gBACzB,CAAC,CAAC,CAAA;gBAEF,OAAO,CAAC,GAAG,CAAC,gCAAgC,KAAK,GAAG,CAAC,CAAA;gBACrD,kCAAkC;gBAClC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAA;YACtB,CAAC;SACF,CAAC;QAEF,SAAS,EAAE,YAAY,CAAqB;YAC1C,IAAI,EAAE,mBAAmB;YACzB,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;gBACxB,+CAA+C;gBAC/C,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;gBAEtB,kEAAkE;gBAClE,oDAAoD;YACtD,CAAC;YACD,IAAI,EAAE;gBACJ,WAAW,EAAE,oCAAoC;aAClD;SACF,CAAC;KACH,CAAC,CAAC,CAAA;IACH,eAAe;IACf,eAAe;AACjB,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { pokemonEndpoints } from '../api.md';
|
|
2
|
-
import { AppConfig } from '../app.config';
|
|
3
|
-
import { PokemonDispatcher } from '../pokemon.dispatcher';
|
|
4
|
-
import { PokemonState } from '../types';
|
|
5
|
-
type PokemonDispatcherType = {
|
|
6
|
-
pokemonDispatcher: PokemonDispatcher;
|
|
7
|
-
};
|
|
8
|
-
type PokemonApiType = {
|
|
9
|
-
pokemonApi: typeof pokemonEndpoints;
|
|
10
|
-
};
|
|
11
|
-
export declare const navigationEffect: import("../../../../dist/reactive").Effect<PokemonState, PokemonDispatcherType, PokemonApiType, AppConfig>;
|
|
12
|
-
export declare const watchIdEffect: import("../../../../dist/reactive").Effect<PokemonState, PokemonDispatcherType, PokemonApiType, AppConfig>;
|
|
13
|
-
export declare const loadPokemonEffect: import("../../../../dist/reactive").Effect<PokemonState, PokemonDispatcherType, PokemonApiType, AppConfig>;
|
|
14
|
-
export declare const pokemonEffects: import("../../../../dist/reactive").Effect<PokemonState, PokemonDispatcherType, PokemonApiType, AppConfig>;
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=pokemon.effects.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pokemon.effects.d.ts","sourceRoot":"","sources":["../../../../src/_examples/pokemons/effects/pokemon.effects.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAW,YAAY,EAAE,MAAM,UAAU,CAAA;AAGhD,KAAK,qBAAqB,GAAG;IAAE,iBAAiB,EAAE,iBAAiB,CAAA;CAAE,CAAA;AACrE,KAAK,cAAc,GAAG;IAAE,UAAU,EAAE,OAAO,gBAAgB,CAAA;CAAE,CAAA;AAG7D,eAAO,MAAM,gBAAgB,4GAQ5B,CAAA;AAGD,eAAO,MAAM,aAAa,4GAezB,CAAA;AAGD,eAAO,MAAM,iBAAiB,4GAgC7B,CAAA;AAGD,eAAO,MAAM,cAAc,4GAAqE,CAAA"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { from, mapTo, of, tap } from 'rxjs';
|
|
2
|
-
import { catchError, switchMap } from 'rxjs/operators';
|
|
3
|
-
import { combineEffects, createEffect, ofType, ofTypes, selectorMap, validateMap } from '../../../../../synapse';
|
|
4
|
-
// Эффект для навигации
|
|
5
|
-
export const navigationEffect = createEffect((action$, state$, { pokemonDispatcher }, _, config) => action$.pipe(ofTypes([pokemonDispatcher.dispatch.next, pokemonDispatcher.dispatch.prev]), switchMap((action) => {
|
|
6
|
-
const { id } = action.payload;
|
|
7
|
-
return of(() => pokemonDispatcher.dispatch.loadPokemon(id));
|
|
8
|
-
})));
|
|
9
|
-
// Эффект для отслеживания изменений ID
|
|
10
|
-
export const watchIdEffect = createEffect((action$, state$, { pokemonDispatcher }) => action$.pipe(ofType(pokemonDispatcher.watchers.watchCurrentId), selectorMap(state$, (state) => state.loading, (state) => state.currentId), tap(([action, [loading, currentId]]) => {
|
|
11
|
-
// console.log(`ID покемона изменился на ${action.payload}`)
|
|
12
|
-
// console.log('Статус загрузки:', loading)
|
|
13
|
-
// console.log('ID в хранилище:', currentId)
|
|
14
|
-
}), mapTo(null)));
|
|
15
|
-
// Эффект для загрузки данных покемона
|
|
16
|
-
export const loadPokemonEffect = createEffect((action$, state$, { pokemonDispatcher }, { pokemonApi }, config) => action$.pipe(ofType(pokemonDispatcher.dispatch.loadPokemon), selectorMap(state$, (state) => state.currentId), validateMap({
|
|
17
|
-
apiCall: ([action, [currentId]]) => {
|
|
18
|
-
const { id } = action.payload;
|
|
19
|
-
return from(pokemonApi.fetchPokemonById.request({ id }).waitWithCallbacks({
|
|
20
|
-
loading: (request) => {
|
|
21
|
-
console.log('LOADING', request);
|
|
22
|
-
pokemonDispatcher.dispatch.loadPokemonRequest(id);
|
|
23
|
-
},
|
|
24
|
-
// success: (data, request) => {
|
|
25
|
-
// console.log('SUCCESS', request)
|
|
26
|
-
// pokemonDispatcher.dispatch.success({ data })
|
|
27
|
-
// },
|
|
28
|
-
// error: (error, request) => {
|
|
29
|
-
// console.log('ERROR', error, request)
|
|
30
|
-
// pokemonDispatcher.dispatch.failure(error!)
|
|
31
|
-
// },
|
|
32
|
-
})).pipe(switchMap(({ data }) => {
|
|
33
|
-
return of(pokemonDispatcher.dispatch.success({ data }));
|
|
34
|
-
}), catchError((err) => of(pokemonDispatcher.dispatch.failure(err))));
|
|
35
|
-
},
|
|
36
|
-
})));
|
|
37
|
-
// Объединяем все эффекты в один и экспортируем
|
|
38
|
-
export const pokemonEffects = combineEffects(navigationEffect, watchIdEffect, loadPokemonEffect);
|
|
39
|
-
//# sourceMappingURL=pokemon.effects.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pokemon.effects.js","sourceRoot":"","sources":["../../../../src/_examples/pokemons/effects/pokemon.effects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAClD,OAAO,EAAE,UAAU,EAAO,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE3D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAUhH,uBAAuB;AACvB,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAiE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,iBAAiB,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,CACjK,OAAO,CAAC,IAAI,CACV,OAAO,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAC3E,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE;IACnB,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC,OAAO,CAAA;IAC7B,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAA;AAC7D,CAAC,CAAC,CACH,CACF,CAAA;AAED,uCAAuC;AACvC,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAiE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,iBAAiB,EAAE,EAAE,EAAE,CACnJ,OAAO,CAAC,IAAI,CACV,MAAM,CAAC,i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AAyC;YACzC,+CAA+C;YAC/C,KAAK;SACN,CAAC,CACH,CAAC,IAAI,CACJ,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;YACrB,OAAO,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QACzD,CAAC,CAAC,EACF,UAAU,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CACjE,CAAA;IACH,CAAC;CACF,CAAC,CACH,CACF,CAAA;AAED,+CAA+C;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC,gBAAgB,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pokenon.middlewares.d.ts","sourceRoot":"","sources":["../../../../src/_examples/pokemons/middlewares/pokenon.middlewares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAIvC,eAAO,MAAM,4BAA4B,QAAO,kBAAkB,CAAC,YAAY,CA0B9E,CAAA"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Создадим счетчик инициализаций
|
|
2
|
-
export const createPokemonAlertMiddleware = () => (api) => (next) => async (action) => {
|
|
3
|
-
const result = await next(action);
|
|
4
|
-
// Проверяем тип после выполнения
|
|
5
|
-
if (action.type.includes('pokemon/next') || action.type.includes('pokemon/prev')) {
|
|
6
|
-
const state = await api.getState();
|
|
7
|
-
// Пробуем найти действие напрямую
|
|
8
|
-
const alertAction = api.findActionByType('pokemon/showAlert');
|
|
9
|
-
if (alertAction) {
|
|
10
|
-
await alertAction({
|
|
11
|
-
message: `Покемон переключен на ID: ${state.currentId}`,
|
|
12
|
-
type: 'info',
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
await api.dispatch({
|
|
17
|
-
type: 'pokemon/showAlert',
|
|
18
|
-
payload: {
|
|
19
|
-
message: `Покемон переключен на ID: ${state.currentId}`,
|
|
20
|
-
type: 'info',
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=pokenon.middlewares.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pokenon.middlewares.js","sourceRoot":"","sources":["../../../../src/_examples/pokemons/middlewares/pokenon.middlewares.ts"],"names":[],"mappings":"AAIA,iCAAiC;AACjC,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAqC,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;IACtH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,CAAA;IACjC,iCAAiC;IACjC,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QACjF,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAA;QAElC,kCAAkC;QAClC,MAAM,WAAW,GAAG,GAAG,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAA;QAE7D,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,WAAW,CAAC;gBAChB,OAAO,EAAE,6BAA6B,KAAK,CAAC,SAAS,EAAE;gBACvD,IAAI,EAAE,MAAM;aACb,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,CAAC,QAAQ,CAAC;gBACjB,IAAI,EAAE,mBAAmB;gBACzB,OAAO,EAAE;oBACP,OAAO,EAAE,6BAA6B,KAAK,CAAC,SAAS,EAAE;oBACvD,IAAI,EAAE,MAAM;iBACb;aACF,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { PokemonStorage } from './storages/pokemon.storage';
|
|
2
|
-
export interface AlertPayload {
|
|
3
|
-
message: string;
|
|
4
|
-
type: 'info' | 'warning' | 'error' | 'success';
|
|
5
|
-
duration?: number;
|
|
6
|
-
}
|
|
7
|
-
export declare function createPokemonDispatcher(storage: PokemonStorage): any;
|
|
8
|
-
export type PokemonDispatcher = ReturnType<typeof createPokemonDispatcher>;
|
|
9
|
-
//# sourceMappingURL=pokemon.dispatcher.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pokemon.dispatcher.d.ts","sourceRoot":"","sources":["../../../src/_examples/pokemons/pokemon.dispatcher.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAI3D,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAGD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,cAAc,OAsI9D;AAGD,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAA"}
|