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,240 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// 'use client'
|
|
3
|
-
//
|
|
4
|
-
// import { useCallback, useState } from 'react'
|
|
5
|
-
// import { ApiClient, ResponseFormat } from 'synapse'
|
|
6
|
-
//
|
|
7
|
-
// export interface PokemonListResponse {
|
|
8
|
-
// count: number
|
|
9
|
-
// next: string | null
|
|
10
|
-
// previous: string | null
|
|
11
|
-
// results: {
|
|
12
|
-
// name: string
|
|
13
|
-
// url: string
|
|
14
|
-
// }[]
|
|
15
|
-
// }
|
|
16
|
-
//
|
|
17
|
-
// export interface PokemonDetails {
|
|
18
|
-
// id: number
|
|
19
|
-
// name: string
|
|
20
|
-
// height: number
|
|
21
|
-
// weight: number
|
|
22
|
-
// sprites: {
|
|
23
|
-
// front_default: string
|
|
24
|
-
// back_default: string
|
|
25
|
-
// other?: {
|
|
26
|
-
// 'official-artwork'?: {
|
|
27
|
-
// front_default: string
|
|
28
|
-
// }
|
|
29
|
-
// }
|
|
30
|
-
// }
|
|
31
|
-
// types: {
|
|
32
|
-
// slot: number
|
|
33
|
-
// type: {
|
|
34
|
-
// name: string
|
|
35
|
-
// url: string
|
|
36
|
-
// }
|
|
37
|
-
// }[]
|
|
38
|
-
// abilities: {
|
|
39
|
-
// ability: {
|
|
40
|
-
// name: string
|
|
41
|
-
// url: string
|
|
42
|
-
// }
|
|
43
|
-
// is_hidden: boolean
|
|
44
|
-
// slot: number
|
|
45
|
-
// }[]
|
|
46
|
-
// stats: {
|
|
47
|
-
// base_stat: number
|
|
48
|
-
// effort: number
|
|
49
|
-
// stat: {
|
|
50
|
-
// name: string
|
|
51
|
-
// url: string
|
|
52
|
-
// }
|
|
53
|
-
// }[]
|
|
54
|
-
// }
|
|
55
|
-
//
|
|
56
|
-
// export interface PokemonSearchParams {
|
|
57
|
-
// limit?: number
|
|
58
|
-
// offset?: number
|
|
59
|
-
// }
|
|
60
|
-
//
|
|
61
|
-
// export const api = new ApiClient({
|
|
62
|
-
// // Перечисляем заголовки которые будут добавлены в локину формирования ключа
|
|
63
|
-
// cacheableHeaderKeys: ['X-Global-Header'],
|
|
64
|
-
// storageType: 'localStorage',
|
|
65
|
-
// storageOptions: {
|
|
66
|
-
// name: 'pokemon-api-storage',
|
|
67
|
-
// dbName: 'pokemon-api-cache',
|
|
68
|
-
// storeName: 'requests',
|
|
69
|
-
// dbVersion: 1,
|
|
70
|
-
// },
|
|
71
|
-
// // Или boolean или объект с настройками
|
|
72
|
-
// cache: {
|
|
73
|
-
// // Время жизни кэша в миллисекундах
|
|
74
|
-
// ttl: 5 * 60 * 1000, // 5 минут
|
|
75
|
-
// // Инвалидировать кэш при ошибке
|
|
76
|
-
// invalidateOnError: true,
|
|
77
|
-
// cleanup: {
|
|
78
|
-
// // Включить периодическую очистку
|
|
79
|
-
// enabled: true,
|
|
80
|
-
// // Интервал очистки в миллисекундах
|
|
81
|
-
// interval: 10 * 60 * 1000, // 10 минут
|
|
82
|
-
// },
|
|
83
|
-
// },
|
|
84
|
-
// baseQuery: {
|
|
85
|
-
// baseUrl: 'https://pokeapi.co/api/v2',
|
|
86
|
-
// // Таймаут запроса в миллисекундах
|
|
87
|
-
// timeout: 10000,
|
|
88
|
-
// prepareHeaders: async (headers, context) => {
|
|
89
|
-
// // Устанавливаем заголовки для тестирования
|
|
90
|
-
// headers.set('X-Global-Header', 'global-value')
|
|
91
|
-
// headers.set('X-BaseQuery-Header', 'basequery-value')
|
|
92
|
-
//
|
|
93
|
-
// // Можем получить значение из localStorage / cookies
|
|
94
|
-
// const profileId = context.getFromStorage<string>('myProfileId')
|
|
95
|
-
// const token = context.getCookie('myToken')
|
|
96
|
-
//
|
|
97
|
-
// // context.someParam - можно получить любые параметры которые передаем в свойство context при вызове метода
|
|
98
|
-
// return headers
|
|
99
|
-
// },
|
|
100
|
-
// credentials: 'same-origin',
|
|
101
|
-
// },
|
|
102
|
-
// // Асинхронная фабрика по созданию эндпоинтов
|
|
103
|
-
// endpoints: async (create) => ({
|
|
104
|
-
// updatePokemonById: create<{ id: number }, PokemonDetails>({
|
|
105
|
-
// // Можно отключить / уточнить для конкретного эндпоинта
|
|
106
|
-
// cache: false,
|
|
107
|
-
// // Исключить заголовки из формирования ключа
|
|
108
|
-
// excludeCacheableHeaderKeys: [],
|
|
109
|
-
// // Включить заголовки из формирования ключа
|
|
110
|
-
// includeCacheableHeaderKeys: [],
|
|
111
|
-
// // Дополнительные уточнения для форпмирования заголовков для конкретного эндпоинта
|
|
112
|
-
// prepareHeaders: async (headers) => headers,
|
|
113
|
-
// tags: [],
|
|
114
|
-
// invalidatesTags: [],
|
|
115
|
-
// // Значения в контексте могут быть те, которые передаем в свойство context при вызове метода
|
|
116
|
-
// request: (id, context) => ({
|
|
117
|
-
// path: `/pokemon/${id}`,
|
|
118
|
-
// method: 'PUT',
|
|
119
|
-
// body: {},
|
|
120
|
-
// }),
|
|
121
|
-
// }),
|
|
122
|
-
// // Запрос деталей покемона по ID (с явно включенным кэшированием)
|
|
123
|
-
// getPokemonById: create<{ id: number }, PokemonDetails>({
|
|
124
|
-
// request: (params) => ({
|
|
125
|
-
// path: `/pokemon/${params.id}`,
|
|
126
|
-
// method: 'GET',
|
|
127
|
-
// responseFormat: ResponseFormat.Json,
|
|
128
|
-
// }),
|
|
129
|
-
// tags: ['pokemon-details'],
|
|
130
|
-
// }),
|
|
131
|
-
// // Запрос списка покемонов (без кэширования)
|
|
132
|
-
// getPokemonList: create<PokemonSearchParams, PokemonListResponse>({
|
|
133
|
-
// request: (
|
|
134
|
-
// params = {
|
|
135
|
-
// limit: 20,
|
|
136
|
-
// offset: 0,
|
|
137
|
-
// },
|
|
138
|
-
// ) => ({
|
|
139
|
-
// path: '/pokemon',
|
|
140
|
-
// method: 'GET',
|
|
141
|
-
// query: params,
|
|
142
|
-
// responseFormat: ResponseFormat.Json,
|
|
143
|
-
// }),
|
|
144
|
-
// }),
|
|
145
|
-
// }),
|
|
146
|
-
// })
|
|
147
|
-
// // Инициализация
|
|
148
|
-
// export const pokemonApi = await api.init()
|
|
149
|
-
// // Демонтирование
|
|
150
|
-
// // await pokemonApi.destroy()
|
|
151
|
-
//
|
|
152
|
-
// // Получение эндпоинтов
|
|
153
|
-
// export const pokemonEndpoints = pokemonApi.getEndpoints()
|
|
154
|
-
//
|
|
155
|
-
// export function Example1() {
|
|
156
|
-
// const [currentPokemon, setCurrentPokemon] = useState<PokemonDetails | undefined>(undefined)
|
|
157
|
-
//
|
|
158
|
-
// const onPokemon = useCallback(async (id: number) => {
|
|
159
|
-
// // Создаем запрос
|
|
160
|
-
// const request = pokemonEndpoints.getPokemonById.request(
|
|
161
|
-
// { id },
|
|
162
|
-
// {
|
|
163
|
-
// // Можно передать дополнительные свойства в контекст
|
|
164
|
-
// context: {
|
|
165
|
-
// someKey: 'someValue',
|
|
166
|
-
// },
|
|
167
|
-
// // Можно отключить кэш для конкретного вызова
|
|
168
|
-
// disableCache: true,
|
|
169
|
-
// // Можно указать заголовки которые будут участвовать в формирование ключа (перетирают все остальные настройки)
|
|
170
|
-
// cacheableHeaderKeys: ['header-key'],
|
|
171
|
-
// // и тд...
|
|
172
|
-
// // Некоторые аспекты еще буду дорабатывать
|
|
173
|
-
// },
|
|
174
|
-
// )
|
|
175
|
-
//
|
|
176
|
-
// // Создаем подписки
|
|
177
|
-
// request.subscribe((state) => {
|
|
178
|
-
// switch (state.status) {
|
|
179
|
-
// case 'idle': {
|
|
180
|
-
// console.log('запрос неактивен')
|
|
181
|
-
// break
|
|
182
|
-
// }
|
|
183
|
-
// case 'loading': {
|
|
184
|
-
// console.log('запрос loading')
|
|
185
|
-
// break
|
|
186
|
-
// }
|
|
187
|
-
// case 'success': {
|
|
188
|
-
// console.log('запрос success')
|
|
189
|
-
// setCurrentPokemon(state.data)
|
|
190
|
-
// break
|
|
191
|
-
// }
|
|
192
|
-
// case 'error': {
|
|
193
|
-
// console.log('запрос error')
|
|
194
|
-
// break
|
|
195
|
-
// }
|
|
196
|
-
// }
|
|
197
|
-
// }, { autoUnsubscribe: true })
|
|
198
|
-
//
|
|
199
|
-
// // Вызываем запрос и получаем response
|
|
200
|
-
// const response = await request.wait()
|
|
201
|
-
// console.log('response', response)
|
|
202
|
-
//
|
|
203
|
-
// // Альтернативный вариант вместо подписок
|
|
204
|
-
// request.waitWithCallbacks({
|
|
205
|
-
// idle: (request) => {},
|
|
206
|
-
// loading: (request) => {},
|
|
207
|
-
// success: (data, request) => {},
|
|
208
|
-
// error: (error, request) => {},
|
|
209
|
-
// }).catch(console.error)
|
|
210
|
-
// }, [])
|
|
211
|
-
//
|
|
212
|
-
// return (
|
|
213
|
-
// <div style={{ display: 'flex', flexDirection: 'column' }}>
|
|
214
|
-
// <h2>{currentPokemon?.name}</h2>
|
|
215
|
-
// <img src={currentPokemon?.sprites.front_default} alt={currentPokemon?.name} />
|
|
216
|
-
// <div>
|
|
217
|
-
// Types:
|
|
218
|
-
// {' '}
|
|
219
|
-
// {currentPokemon?.types.map((t) => t.type.name).join(', ')}
|
|
220
|
-
// </div>
|
|
221
|
-
// <div>
|
|
222
|
-
// <button
|
|
223
|
-
// onClick={() => onPokemon((currentPokemon?.id || 0) + 1)}
|
|
224
|
-
// >
|
|
225
|
-
// Next
|
|
226
|
-
// </button>
|
|
227
|
-
// <span>
|
|
228
|
-
// Pokemon #
|
|
229
|
-
// {currentPokemon?.id}
|
|
230
|
-
// </span>
|
|
231
|
-
// <button
|
|
232
|
-
// onClick={() => onPokemon((currentPokemon?.id || 0) - 1)}
|
|
233
|
-
// >
|
|
234
|
-
// Previous
|
|
235
|
-
// </button>
|
|
236
|
-
// </div>
|
|
237
|
-
// </div>
|
|
238
|
-
// )
|
|
239
|
-
// }
|
|
240
|
-
//# sourceMappingURL=example1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"example1.js","sourceRoot":"","sources":["../../src/_examples/example1.tsx"],"names":[],"mappings":";AAAA,eAAe;AACf,EAAE;AACF,gDAAgD;AAChD,sDAAsD;AACtD,EAAE;AACF,yCAAyC;AACzC,kBAAkB;AAClB,wBAAwB;AACxB,4BAA4B;AAC5B,eAAe;AACf,mBAAmB;AACnB,kBAAkB;AAClB,QAAQ;AACR,IAAI;AACJ,EAAE;AACF,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,YAAY;AACZ,UAAU;AACV,oCAAoC;AACpC,EAAE;AACF,6CAA6C;AAC7C,4CAA4C;AAC5C,wCAAwC;AACxC,EAAE;AACF,gDAAgD;AAChD,kCAAkC;AAClC,+BAA+B;AAC/B,kCAAkC;AAClC,wCAAwC;AACxC,uCAAuC;AACvC,8BAA8B;AAC9B,WAAW;AACX,EAAE;AACF,aAAa;AACb,iEAAiE;AACjE,wCAAwC;AACxC,uFAAuF;AACvF,cAAc;AACd,iBAAiB;AACjB,gBAAgB;AAChB,qEAAqE;AACrE,eAAe;AACf,cAAc;AACd,kBAAkB;AAClB,qEAAqE;AACrE,YAAY;AACZ,iBAAiB;AACjB,oBAAoB;AACpB,iBAAiB;AACjB,sBAAsB;AACtB,iCAAiC;AACjC,kBAAkB;AAClB,kBAAkB;AAClB,qEAAqE;AACrE,YAAY;AACZ,qBAAqB;AACrB,oBAAoB;AACpB,eAAe;AACf,aAAa;AACb,MAAM;AACN,IAAI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=example2.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"example2.d.ts","sourceRoot":"","sources":["../../src/_examples/example2.tsx"],"names":[],"mappings":""}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// 'use client'
|
|
3
|
-
//
|
|
4
|
-
// import { useEffect, useState } from 'react'
|
|
5
|
-
// import { broadcastMiddleware, IndexedDBStorage, LocalStorage, MemoryStorage } from 'synapse'
|
|
6
|
-
//
|
|
7
|
-
// interface Counter {
|
|
8
|
-
// value: number
|
|
9
|
-
// }
|
|
10
|
-
//
|
|
11
|
-
// const counter1 = await new MemoryStorage<Counter>({
|
|
12
|
-
// name: 'counter1',
|
|
13
|
-
// initialState: { value: 1 },
|
|
14
|
-
// }).initialize()
|
|
15
|
-
//
|
|
16
|
-
// const counter2 = await new IndexedDBStorage<Counter>({
|
|
17
|
-
// name: 'counter2',
|
|
18
|
-
// options: {
|
|
19
|
-
// dbVersion: 2,
|
|
20
|
-
// storeName: 'counter23',
|
|
21
|
-
// dbName: 'counter23',
|
|
22
|
-
// },
|
|
23
|
-
// initialState: { value: 2 },
|
|
24
|
-
// }).initialize()
|
|
25
|
-
//
|
|
26
|
-
// const counter3 = await new LocalStorage<Counter>({
|
|
27
|
-
// name: 'counter3',
|
|
28
|
-
// initialState: { value: 3 },
|
|
29
|
-
// }).initialize()
|
|
30
|
-
//
|
|
31
|
-
// // Подписка на все изменения в данном хранилище
|
|
32
|
-
// counter2.subscribeToAll((event) => {
|
|
33
|
-
// const { key, type, value } = event
|
|
34
|
-
// console.log('counter1.subscribeToAll', type, key, value)
|
|
35
|
-
// })
|
|
36
|
-
// // Подписка на конкретное значение (первый параметр - колбэк)
|
|
37
|
-
// counter2.subscribe((s) => s.value, (event) => {
|
|
38
|
-
// console.log('counter1.subscribe--1', event)
|
|
39
|
-
// })
|
|
40
|
-
// // Подписка на конкретное значение (первый параметр - путь до свойства)
|
|
41
|
-
// counter2.subscribe('value', (event) => {
|
|
42
|
-
// console.log('counter1.subscribe--2', event)
|
|
43
|
-
// })
|
|
44
|
-
//
|
|
45
|
-
// // React компонент
|
|
46
|
-
// export function TestCounter() {
|
|
47
|
-
// const [counterValue1, setCounterValue1] = useState(0)
|
|
48
|
-
// const [counterValue2, setCounterValue2] = useState(0)
|
|
49
|
-
// const [counterValue3, setCounterValue3] = useState(0)
|
|
50
|
-
//
|
|
51
|
-
// useEffect(() => {
|
|
52
|
-
// counter1.subscribe('value', setCounterValue1)
|
|
53
|
-
// }, [])
|
|
54
|
-
// useEffect(() => {
|
|
55
|
-
// counter2.subscribe((s) => s.value, setCounterValue2)
|
|
56
|
-
// }, [])
|
|
57
|
-
// useEffect(() => {
|
|
58
|
-
// counter3.subscribe((s) => s.value, setCounterValue3)
|
|
59
|
-
// }, [])
|
|
60
|
-
//
|
|
61
|
-
// const updateCounter1 = async () => {
|
|
62
|
-
// await counter1.update((state) => {
|
|
63
|
-
// state.value++
|
|
64
|
-
// })
|
|
65
|
-
// }
|
|
66
|
-
// const updateCounter2 = async () => {
|
|
67
|
-
// await counter2.set('value', counterValue2 + 1)
|
|
68
|
-
// }
|
|
69
|
-
// const updateCounter3 = async () => {
|
|
70
|
-
// await counter3.update((state) => state.value++)
|
|
71
|
-
// }
|
|
72
|
-
//
|
|
73
|
-
// return (
|
|
74
|
-
// <div style={{ display: 'flex', gap: '50px'}}>
|
|
75
|
-
// <button onClick={updateCounter1}>{counterValue1}</button>
|
|
76
|
-
// <button onClick={updateCounter2}>{counterValue2}</button>
|
|
77
|
-
// <button onClick={updateCounter3}>{counterValue3}</button>
|
|
78
|
-
// </div>
|
|
79
|
-
// )
|
|
80
|
-
// }
|
|
81
|
-
//# sourceMappingURL=example2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"example2.js","sourceRoot":"","sources":["../../src/_examples/example2.tsx"],"names":[],"mappings":";AAAA,eAAe;AACf,EAAE;AACF,8CAA8C;AAC9C,+FAA+F;AAC/F,EAAE;AACF,sBAAsB;AACtB,kBAAkB;AAClB,IAAI;AACJ,EAAE;AACF,sDAAsD;AACtD,sBAAsB;AACtB,gCAAgC;AAChC,kBAAkB;AAClB,EAAE;AACF,yDAAyD;AACzD,sBAAsB;AACtB,eAAe;AACf,oBAAoB;AACpB,8BAA8B;AAC9B,2BAA2B;AAC3B,OAAO;AACP,gCAAgC;AAChC,kBAAkB;AAClB,EAAE;AACF,qDAAqD;AACrD,sBAAsB;AACtB,gCAAgC;AAChC,kBAAkB;AAClB,EAAE;AACF,kDAAkD;AAClD,uCAAuC;AACvC,uCAAuC;AACvC,6DAA6D;AAC7D,KAAK;AACL,gEAAgE;AAChE,kDAAkD;AAClD,gDAAgD;AAChD,KAAK;AACL,0EAA0E;AAC1E,2CAA2C;AAC3C,gDAAgD;AAChD,KAAK;AACL,EAAE;AACF,qBAAqB;AACrB,kCAAkC;AAClC,0DAA0D;AAC1D,0DAA0D;AAC1D,0DAA0D;AAC1D,EAAE;AACF,sBAAsB;AACtB,oDAAoD;AACpD,WAAW;AACX,sBAAsB;AACtB,2DAA2D;AAC3D,WAAW;AACX,sBAAsB;AACtB,2DAA2D;AAC3D,WAAW;AACX,EAAE;AACF,yCAAyC;AACzC,yCAAyC;AACzC,sBAAsB;AACtB,SAAS;AACT,MAAM;AACN,yCAAyC;AACzC,qDAAqD;AACrD,MAAM;AACN,yCAAyC;AACzC,sDAAsD;AACtD,MAAM;AACN,EAAE;AACF,aAAa;AACb,oDAAoD;AACpD,oEAAoE;AACpE,oEAAoE;AACpE,oEAAoE;AACpE,aAAa;AACb,MAAM;AACN,IAAI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=example3.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"example3.d.ts","sourceRoot":"","sources":["../../src/_examples/example3.tsx"],"names":[],"mappings":""}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// 'use client'
|
|
3
|
-
//
|
|
4
|
-
// import { useEffect, useState } from 'react'
|
|
5
|
-
// import { broadcastMiddleware, IndexedDBStorage, LocalStorage, MemoryStorage } from 'synapse'
|
|
6
|
-
//
|
|
7
|
-
// interface Counter {
|
|
8
|
-
// value: number
|
|
9
|
-
// }
|
|
10
|
-
//
|
|
11
|
-
// const counter1 = await new MemoryStorage<Counter>({
|
|
12
|
-
// name: 'counter1',
|
|
13
|
-
// initialState: { value: 1 },
|
|
14
|
-
// middlewares: (getDefaultMiddleware) => {
|
|
15
|
-
// const { shallowCompare, batching } = getDefaultMiddleware()
|
|
16
|
-
// return [
|
|
17
|
-
// broadcastMiddleware({
|
|
18
|
-
// storageName: 'counter1',
|
|
19
|
-
// storageType: 'memory',
|
|
20
|
-
// }),
|
|
21
|
-
// shallowCompare(),
|
|
22
|
-
// batching(),
|
|
23
|
-
// ]
|
|
24
|
-
// },
|
|
25
|
-
// }).initialize()
|
|
26
|
-
//
|
|
27
|
-
// const counter2 = await new IndexedDBStorage<Counter>({
|
|
28
|
-
// name: 'counter2',
|
|
29
|
-
// options: {
|
|
30
|
-
// dbVersion: 2,
|
|
31
|
-
// storeName: 'counter23',
|
|
32
|
-
// dbName: 'counter23',
|
|
33
|
-
// },
|
|
34
|
-
// initialState: { value: 2 },
|
|
35
|
-
// }).initialize()
|
|
36
|
-
//
|
|
37
|
-
// const counter3 = await new LocalStorage<Counter>({
|
|
38
|
-
// name: 'counter3',
|
|
39
|
-
// initialState: { value: 3 },
|
|
40
|
-
// }).initialize()
|
|
41
|
-
//
|
|
42
|
-
// // Подписка на все изменения в данном хранилище
|
|
43
|
-
// // counter1.subscribeToAll((event) => {
|
|
44
|
-
// // const { key, type, value } = event
|
|
45
|
-
// // console.log('counter1.subscribeToAll', type, key, value)
|
|
46
|
-
// // })
|
|
47
|
-
// // // Подписка на конкретное значение (первый параметр - колбэк)
|
|
48
|
-
// // counter1.subscribe((s) => s.value, (event) => {
|
|
49
|
-
// // console.log('counter1.subscribe--1', event)
|
|
50
|
-
// // })
|
|
51
|
-
// // // Подписка на конкретное значение (первый параметр - путь до свойства)
|
|
52
|
-
// // counter1.subscribe('value', (event) => {
|
|
53
|
-
// // console.log('counter1.subscribe--2', event)
|
|
54
|
-
// // })
|
|
55
|
-
//
|
|
56
|
-
// // React компонент
|
|
57
|
-
// export function TestCounter2() {
|
|
58
|
-
// const [counterValue1, setCounterValue1] = useState(0)
|
|
59
|
-
// const [counterValue2, setCounterValue2] = useState(0)
|
|
60
|
-
// const [counterValue3, setCounterValue3] = useState(0)
|
|
61
|
-
//
|
|
62
|
-
// useEffect(() => {
|
|
63
|
-
// const d = counter1.subscribe('value', (v) => {
|
|
64
|
-
// console.log('ppppp')
|
|
65
|
-
// setCounterValue1(v)
|
|
66
|
-
// })
|
|
67
|
-
//
|
|
68
|
-
// return () => {
|
|
69
|
-
// d()
|
|
70
|
-
// }
|
|
71
|
-
// }, [])
|
|
72
|
-
// useEffect(() => {
|
|
73
|
-
// counter2.subscribe((s) => s.value, setCounterValue2)
|
|
74
|
-
// }, [])
|
|
75
|
-
// useEffect(() => {
|
|
76
|
-
// counter3.subscribe((s) => s.value, setCounterValue3)
|
|
77
|
-
// }, [])
|
|
78
|
-
//
|
|
79
|
-
// const updateCounter1 = async () => {
|
|
80
|
-
// await counter1.update((state) => {
|
|
81
|
-
// state.value++
|
|
82
|
-
// })
|
|
83
|
-
// }
|
|
84
|
-
// const updateCounter2 = async () => {
|
|
85
|
-
// await counter2.set('value', counterValue2 + 1)
|
|
86
|
-
// }
|
|
87
|
-
// const updateCounter3 = async () => {
|
|
88
|
-
// await counter3.update((state) => state.value++)
|
|
89
|
-
// }
|
|
90
|
-
//
|
|
91
|
-
// return (
|
|
92
|
-
// <div style={{ display: 'flex', gap: '50px' }}>
|
|
93
|
-
// <button onClick={updateCounter1}>{counterValue1}</button>
|
|
94
|
-
// <button onClick={updateCounter2}>{counterValue2}</button>
|
|
95
|
-
// <button onClick={updateCounter3}>{counterValue3}</button>
|
|
96
|
-
// </div>
|
|
97
|
-
// )
|
|
98
|
-
// }
|
|
99
|
-
//# sourceMappingURL=example3.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"example3.js","sourceRoot":"","sources":["../../src/_examples/example3.tsx"],"names":[],"mappings":";AAAA,eAAe;AACf,EAAE;AACF,8CAA8C;AAC9C,+FAA+F;AAC/F,EAAE;AACF,sBAAsB;AACtB,kBAAkB;AAClB,IAAI;AACJ,EAAE;AACF,sDAAsD;AACtD,sBAAsB;AACtB,gCAAgC;AAChC,6CAA6C;AAC7C,kEAAkE;AAClE,eAAe;AACf,8BAA8B;AAC9B,mCAAmC;AACnC,iCAAiC;AACjC,YAAY;AACZ,0BAA0B;AAC1B,oBAAoB;AACpB,QAAQ;AACR,OAAO;AACP,kBAAkB;AAClB,EAAE;AACF,yDAAyD;AACzD,sBAAsB;AACtB,eAAe;AACf,oBAAoB;AACpB,8BAA8B;AAC9B,2BAA2B;AAC3B,OAAO;AACP,gCAAgC;AAChC,kBAAkB;AAClB,EAAE;AACF,qDAAqD;AACrD,sBAAsB;AACtB,gCAAgC;AAChC,kBAAkB;AAClB,EAAE;AACF,kDAAkD;AAClD,0CAA0C;AAC1C,0CAA0C;AAC1C,gEAAgE;AAChE,QAAQ;AACR,mEAAmE;AACnE,qDAAqD;AACrD,mDAAmD;AACnD,QAAQ;AACR,6EAA6E;AAC7E,8CAA8C;AAC9C,mDAAmD;AACnD,QAAQ;AACR,EAAE;AACF,qBAAqB;AACrB,mCAAmC;AACnC,0DAA0D;AAC1D,0DAA0D;AAC1D,0DAA0D;AAC1D,EAAE;AACF,sBAAsB;AACtB,qDAAqD;AACrD,6BAA6B;AAC7B,4BAA4B;AAC5B,SAAS;AACT,EAAE;AACF,qBAAqB;AACrB,YAAY;AACZ,QAAQ;AACR,WAAW;AACX,sBAAsB;AACtB,2DAA2D;AAC3D,WAAW;AACX,sBAAsB;AACtB,2DAA2D;AAC3D,WAAW;AACX,EAAE;AACF,yCAAyC;AACzC,yCAAyC;AACzC,sBAAsB;AACtB,SAAS;AACT,MAAM;AACN,yCAAyC;AACzC,qDAAqD;AACrD,MAAM;AACN,yCAAyC;AACzC,sDAAsD;AACtD,MAAM;AACN,EAAE;AACF,aAAa;AACb,qDAAqD;AACrD,kEAAkE;AAClE,kEAAkE;AAClE,kEAAkE;AAClE,aAAa;AACb,MAAM;AACN,IAAI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=example4.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"example4.d.ts","sourceRoot":"","sources":["../../src/_examples/example4.tsx"],"names":[],"mappings":""}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import React, { useEffect, useState } from 'react'
|
|
3
|
-
// import { broadcastMiddleware, MemoryStorage } from 'synapse'
|
|
4
|
-
//
|
|
5
|
-
// // Типы данных
|
|
6
|
-
// interface Counter {
|
|
7
|
-
// value: number;
|
|
8
|
-
// lastUpdated?: Date;
|
|
9
|
-
// }
|
|
10
|
-
//
|
|
11
|
-
// // Создаем хранилища
|
|
12
|
-
// const counter1 = await new MemoryStorage<Counter>({
|
|
13
|
-
// name: 'counter1',
|
|
14
|
-
// initialState: { value: 0 },
|
|
15
|
-
// middlewares: () => [
|
|
16
|
-
// broadcastMiddleware({
|
|
17
|
-
// storageName: 'counter1',
|
|
18
|
-
// storageType: 'memory',
|
|
19
|
-
// }),
|
|
20
|
-
// ],
|
|
21
|
-
// }).initialize()
|
|
22
|
-
//
|
|
23
|
-
// const counter2 = await new MemoryStorage<Counter>({
|
|
24
|
-
// name: 'counter2',
|
|
25
|
-
// initialState: { value: 0 },
|
|
26
|
-
// middlewares: (getDefaultMiddleware) => {
|
|
27
|
-
// const { shallowCompare } = getDefaultMiddleware()
|
|
28
|
-
// return [
|
|
29
|
-
// shallowCompare(),
|
|
30
|
-
// ]
|
|
31
|
-
// },
|
|
32
|
-
// }).initialize()
|
|
33
|
-
//
|
|
34
|
-
// counter1.subscribe((s) => s.value, (v) => {
|
|
35
|
-
// console.log('1_1_1', v)
|
|
36
|
-
// })
|
|
37
|
-
//
|
|
38
|
-
// const counter3 = await new MemoryStorage<Counter>({
|
|
39
|
-
// name: 'counter3',
|
|
40
|
-
// initialState: { value: 10 },
|
|
41
|
-
// middlewares: (getDefaultMiddleware) => {
|
|
42
|
-
// const { batching } = getDefaultMiddleware()
|
|
43
|
-
// return [
|
|
44
|
-
// batching({
|
|
45
|
-
// batchSize: 4,
|
|
46
|
-
// batchDelay: 200,
|
|
47
|
-
// }),
|
|
48
|
-
// ]
|
|
49
|
-
// },
|
|
50
|
-
// }).initialize()
|
|
51
|
-
//
|
|
52
|
-
// // Компонент для демонстрации работы middleware
|
|
53
|
-
//
|
|
54
|
-
// export const Example4 = React.memo(() => {
|
|
55
|
-
// const [counter1Value, setCounter1Value] = useState(0)
|
|
56
|
-
// const [counter2Value, setCounter2Value] = useState(0)
|
|
57
|
-
// const [counter3Value, setCounter3Value] = useState(0)
|
|
58
|
-
//
|
|
59
|
-
// useEffect(() => {
|
|
60
|
-
// // Подписываемся на изменения counter1
|
|
61
|
-
// const unsubscribe1 = counter1.subscribe((s) => s.value, (v) => {
|
|
62
|
-
// console.log('1')
|
|
63
|
-
// setCounter1Value(v)
|
|
64
|
-
// })
|
|
65
|
-
//
|
|
66
|
-
// // Отписываемся при размонтировании
|
|
67
|
-
// return () => {
|
|
68
|
-
// unsubscribe1()
|
|
69
|
-
// }
|
|
70
|
-
// }, [])
|
|
71
|
-
//
|
|
72
|
-
// useEffect(() => {
|
|
73
|
-
// // Подписываемся на изменения counter1
|
|
74
|
-
// const unsubscribe2 = counter2.subscribe((s) => s.value, (v) => {
|
|
75
|
-
// console.log('2')
|
|
76
|
-
// setCounter2Value(v)
|
|
77
|
-
// })
|
|
78
|
-
//
|
|
79
|
-
// // Отписываемся при размонтировании
|
|
80
|
-
// return () => {
|
|
81
|
-
// unsubscribe2()
|
|
82
|
-
// }
|
|
83
|
-
// }, [])
|
|
84
|
-
// useEffect(() => {
|
|
85
|
-
// // Подписываемся на изменения counter1
|
|
86
|
-
// const unsubscribe3 = counter3.subscribe((s) => s.value, (v) => {
|
|
87
|
-
// console.log('3', v)
|
|
88
|
-
// setCounter3Value(v)
|
|
89
|
-
// })
|
|
90
|
-
//
|
|
91
|
-
// // Отписываемся при размонтировании
|
|
92
|
-
// return () => {
|
|
93
|
-
// unsubscribe3()
|
|
94
|
-
// }
|
|
95
|
-
// }, [])
|
|
96
|
-
//
|
|
97
|
-
// // Функции для обновления счетчиков
|
|
98
|
-
// const updateCounter1 = async () => {
|
|
99
|
-
// await counter1.update((state) => {
|
|
100
|
-
// state.value++
|
|
101
|
-
// })
|
|
102
|
-
// }
|
|
103
|
-
//
|
|
104
|
-
// const updateCounter2 = async () => {
|
|
105
|
-
// await counter2.update((state) => {
|
|
106
|
-
// state.value = 100
|
|
107
|
-
// })
|
|
108
|
-
// await counter2.update((state) => {
|
|
109
|
-
// state.value = 100
|
|
110
|
-
// })
|
|
111
|
-
// await counter2.update((state) => {
|
|
112
|
-
// state.value = 100
|
|
113
|
-
// })
|
|
114
|
-
// }
|
|
115
|
-
//
|
|
116
|
-
// const updateCounter3 = async () => {
|
|
117
|
-
// // Отправка нескольких обновлений подряд - должны быть объединены batching
|
|
118
|
-
// await counter3.set('value', counter3Value + 1)
|
|
119
|
-
// }
|
|
120
|
-
//
|
|
121
|
-
// return (
|
|
122
|
-
// <div style={{ fontFamily: 'Arial', padding: '20px' }}>
|
|
123
|
-
// <h2>Middleware Testing</h2>
|
|
124
|
-
//
|
|
125
|
-
// <div style={{ display: 'flex', gap: '20px', marginBottom: '20px' }}>
|
|
126
|
-
// <div style={{ border: '1px solid #ccc', padding: '15px', borderRadius: '5px' }}>
|
|
127
|
-
// <h3>Counter 1 (Both Middlewares)</h3>
|
|
128
|
-
// <p>
|
|
129
|
-
// Value:
|
|
130
|
-
// {counter1Value}
|
|
131
|
-
// </p>
|
|
132
|
-
// <button
|
|
133
|
-
// onClick={updateCounter1}
|
|
134
|
-
// style={{ padding: '8px 15px', backgroundColor: '#4CAF50', color: 'white', border: 'none', borderRadius: '4px' }}
|
|
135
|
-
// >
|
|
136
|
-
// Increment
|
|
137
|
-
// </button>
|
|
138
|
-
// </div>
|
|
139
|
-
//
|
|
140
|
-
// <div style={{ border: '1px solid #ccc', padding: '15px', borderRadius: '5px' }}>
|
|
141
|
-
// <h3>Counter 2 (ShallowCompare)</h3>
|
|
142
|
-
// <p>
|
|
143
|
-
// Value:
|
|
144
|
-
// {counter2Value}
|
|
145
|
-
// </p>
|
|
146
|
-
// <button
|
|
147
|
-
// onClick={updateCounter2}
|
|
148
|
-
// style={{ padding: '8px 15px', backgroundColor: '#2196F3', color: 'white', border: 'none', borderRadius: '4px' }}
|
|
149
|
-
// >
|
|
150
|
-
// Update
|
|
151
|
-
// </button>
|
|
152
|
-
// <p><small>Every 3rd click tries to set the same value</small></p>
|
|
153
|
-
// </div>
|
|
154
|
-
//
|
|
155
|
-
// <div style={{ border: '1px solid #ccc', padding: '15px', borderRadius: '5px' }}>
|
|
156
|
-
// <h3>Counter 3 (Batching)</h3>
|
|
157
|
-
// <p>
|
|
158
|
-
// Value:
|
|
159
|
-
// {counter3Value}
|
|
160
|
-
// </p>
|
|
161
|
-
// <button
|
|
162
|
-
// onClick={updateCounter3}
|
|
163
|
-
// style={{ padding: '8px 15px', backgroundColor: '#FF9800', color: 'white', border: 'none', borderRadius: '4px' }}
|
|
164
|
-
// >
|
|
165
|
-
// Batch Update
|
|
166
|
-
// </button>
|
|
167
|
-
// </div>
|
|
168
|
-
// </div>
|
|
169
|
-
// </div>
|
|
170
|
-
// )
|
|
171
|
-
// })
|
|
172
|
-
//# sourceMappingURL=example4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"example4.js","sourceRoot":"","sources":["../../src/_examples/example4.tsx"],"names":[],"mappings":";AAAA,qDAAqD;AACrD,+DAA+D;AAC/D,EAAE;AACF,iBAAiB;AACjB,sBAAsB;AACtB,mBAAmB;AACnB,wBAAwB;AACxB,IAAI;AACJ,EAAE;AACF,uBAAuB;AACvB,sDAAsD;AACtD,sBAAsB;AACtB,gCAAgC;AAChC,yBAAyB;AACzB,4BAA4B;AAC5B,iCAAiC;AACjC,+BAA+B;AAC/B,UAAU;AACV,OAAO;AACP,kBAAkB;AAClB,EAAE;AACF,sDAAsD;AACtD,sBAAsB;AACtB,gCAAgC;AAChC,6CAA6C;AAC7C,wDAAwD;AACxD,eAAe;AACf,0BAA0B;AAC1B,QAAQ;AACR,OAAO;AACP,kBAAkB;AAClB,EAAE;AACF,8CAA8C;AAC9C,4BAA4B;AAC5B,KAAK;AACL,EAAE;AACF,sDAAsD;AACtD,sBAAsB;AACtB,iCAAiC;AACjC,6CAA6C;AAC7C,kDAAkD;AAClD,eAAe;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C/H,cAAc;AACd,wBAAwB;AACxB,sBAAsB;AACtB,iBAAiB;AACjB,EAAE;AACF,2FAA2F;AAC3F,gDAAgD;AAChD,gBAAgB;AAChB,qBAAqB;AACrB,8BAA8B;AAC9B,iBAAiB;AACjB,oBAAoB;AACpB,uCAAuC;AACvC,+HAA+H;AAC/H,cAAc;AACd,qBAAqB;AACrB,sBAAsB;AACtB,8EAA8E;AAC9E,iBAAiB;AACjB,EAAE;AACF,2FAA2F;AAC3F,0CAA0C;AAC1C,gBAAgB;AAChB,qBAAqB;AACrB,8BAA8B;AAC9B,iBAAiB;AACjB,oBAAoB;AACpB,uCAAuC;AACvC,+HAA+H;AAC/H,cAAc;AACd,2BAA2B;AAC3B,sBAAsB;AACtB,iBAAiB;AACjB,eAAe;AACf,aAAa;AACb,MAAM;AACN,KAAK"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=example5.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"example5.d.ts","sourceRoot":"","sources":["../../src/_examples/example5.tsx"],"names":[],"mappings":""}
|