teamplay 0.4.0-alpha.99 → 0.4.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/orm/Compat/hooksCompat.js +32 -22
- package/package.json +8 -8
|
@@ -115,48 +115,54 @@ export function useAsyncDoc (collection, id, options) {
|
|
|
115
115
|
return [$doc.get(), $doc]
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
function useSubscribedQuery (collection, query, options, hookName, subscribe) {
|
|
119
|
+
const normalizedQuery = normalizeQuery(query, hookName)
|
|
120
|
+
const $collection = getCollectionSignal(collection, query, hookName)
|
|
121
|
+
const $query = subscribe($collection, normalizedQuery, options)
|
|
122
|
+
return {
|
|
123
|
+
normalizedQuery,
|
|
124
|
+
$collection,
|
|
125
|
+
$query: getExtraQuerySignal($query, normalizedQuery)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function getExtraQuerySignal ($query, normalizedQuery) {
|
|
130
|
+
if (!$query) return $query
|
|
131
|
+
return isExtraQuery(normalizedQuery) ? $query.extra : $query
|
|
132
|
+
}
|
|
133
|
+
|
|
118
134
|
export function useQuery$ (collection, query, options) {
|
|
119
|
-
const normalizedQuery = normalizeQuery(query, 'useQuery')
|
|
120
|
-
const $collection = getCollectionSignal(collection, query, 'useQuery')
|
|
121
135
|
const normalizedOptions = normalizeSyncSubOptions(options)
|
|
122
|
-
const $query =
|
|
123
|
-
return
|
|
136
|
+
const { $query } = useSubscribedQuery(collection, query, normalizedOptions, 'useQuery', useSub)
|
|
137
|
+
return $query
|
|
124
138
|
}
|
|
125
139
|
|
|
126
140
|
export function useQuery (collection, query, options) {
|
|
127
|
-
const $collection = getCollectionSignal(collection, query, 'useQuery')
|
|
128
141
|
const normalizedOptions = normalizeSyncSubOptions(options)
|
|
129
|
-
const $query =
|
|
142
|
+
const { $collection, $query } = useSubscribedQuery(collection, query, normalizedOptions, 'useQuery', useSub)
|
|
130
143
|
return [$query.get(), $collection]
|
|
131
144
|
}
|
|
132
145
|
|
|
133
146
|
export function useAsyncQuery$ (collection, query, options) {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
const $query = useAsyncSub($collection, normalizedQuery, options)
|
|
137
|
-
if (!$query) return $query
|
|
138
|
-
return isExtraQuery(normalizedQuery) ? $query.extra : $query
|
|
147
|
+
const { $query } = useSubscribedQuery(collection, query, options, 'useAsyncQuery', useAsyncSub)
|
|
148
|
+
return $query
|
|
139
149
|
}
|
|
140
150
|
|
|
141
151
|
export function useAsyncQuery (collection, query, options) {
|
|
142
|
-
const $collection =
|
|
143
|
-
const $query = useAsyncSub($collection, normalizeQuery(query, 'useAsyncQuery'), options)
|
|
152
|
+
const { $collection, $query } = useSubscribedQuery(collection, query, options, 'useAsyncQuery', useAsyncSub)
|
|
144
153
|
if (!$query) return [undefined, $collection]
|
|
145
154
|
return [$query.get(), $collection]
|
|
146
155
|
}
|
|
147
156
|
|
|
148
157
|
export function useBatchQuery$ (collection, query, _options) {
|
|
149
|
-
const
|
|
150
|
-
const $
|
|
151
|
-
|
|
152
|
-
const $query = useSub($collection, normalizedQuery, options)
|
|
153
|
-
if (!$query) return $query
|
|
154
|
-
return isExtraQuery(normalizedQuery) ? $query.extra : $query
|
|
158
|
+
const options = normalizeBatchSubOptions(_options)
|
|
159
|
+
const { $query } = useSubscribedQuery(collection, query, options, 'useBatchQuery', useSub)
|
|
160
|
+
return $query
|
|
155
161
|
}
|
|
156
162
|
|
|
157
|
-
export function useBatchQuery (collection, query,
|
|
158
|
-
const
|
|
159
|
-
const $query =
|
|
163
|
+
export function useBatchQuery (collection, query, _options) {
|
|
164
|
+
const options = normalizeBatchSubOptions(_options)
|
|
165
|
+
const { $collection, $query } = useSubscribedQuery(collection, query, options, 'useBatchQuery', useSub)
|
|
160
166
|
if (!$query) return [undefined, $collection]
|
|
161
167
|
return [$query.get(), $collection]
|
|
162
168
|
}
|
|
@@ -359,6 +365,10 @@ function normalizeSyncSubOptions (options) {
|
|
|
359
365
|
}
|
|
360
366
|
}
|
|
361
367
|
|
|
368
|
+
function normalizeBatchSubOptions (options) {
|
|
369
|
+
return options ? { ...options, ...BATCH_SUB_OPTIONS } : BATCH_SUB_OPTIONS
|
|
370
|
+
}
|
|
371
|
+
|
|
362
372
|
export const __COMPAT_BATCH_READY__ = {
|
|
363
373
|
isQueryReady
|
|
364
374
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teamplay",
|
|
3
|
-
"version": "0.4.0
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Full-stack signals ORM with multiplayer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@nx-js/observer-util": "^4.1.3",
|
|
37
37
|
"@startupjs/sharedb-mingo-memory": "^4.0.0-2",
|
|
38
|
-
"@teamplay/backend": "^0.4.0
|
|
39
|
-
"@teamplay/cache": "^0.4.0
|
|
40
|
-
"@teamplay/channel": "^0.4.0
|
|
41
|
-
"@teamplay/debug": "^0.4.0
|
|
42
|
-
"@teamplay/schema": "^0.4.0
|
|
43
|
-
"@teamplay/utils": "^0.4.0
|
|
38
|
+
"@teamplay/backend": "^0.4.0",
|
|
39
|
+
"@teamplay/cache": "^0.4.0",
|
|
40
|
+
"@teamplay/channel": "^0.4.0",
|
|
41
|
+
"@teamplay/debug": "^0.4.0",
|
|
42
|
+
"@teamplay/schema": "^0.4.0",
|
|
43
|
+
"@teamplay/utils": "^0.4.0",
|
|
44
44
|
"diff-match-patch": "^1.0.5",
|
|
45
45
|
"events": "^3.3.0",
|
|
46
46
|
"json0-ot-diff": "^1.1.2",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
]
|
|
84
84
|
},
|
|
85
85
|
"license": "MIT",
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "c944a34b27e2dbbe5c81b1c39739caa012212e3f"
|
|
87
87
|
}
|