dreaction-react-native 1.0.0 → 1.1.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/lib/dreaction.d.ts +2 -1
- package/lib/dreaction.d.ts.map +1 -1
- package/lib/dreaction.js +12 -1
- package/package.json +1 -1
- package/src/dreaction.ts +17 -5
package/lib/dreaction.d.ts
CHANGED
|
@@ -20,7 +20,8 @@ export interface ReactotronReactNative extends Reactotron, ReactNativePluginFeat
|
|
|
20
20
|
useReactNative: (options?: UseReactNativeOptions) => this;
|
|
21
21
|
asyncStorageHandler?: AsyncStorageStatic;
|
|
22
22
|
setAsyncStorageHandler: (asyncStorage: AsyncStorageStatic) => this;
|
|
23
|
-
registerDataWatcher: (name: string, type: DataWatchPayload['type']) => {
|
|
23
|
+
registerDataWatcher: <T = unknown>(name: string, type: DataWatchPayload['type']) => {
|
|
24
|
+
currentDebugValue: T | undefined;
|
|
24
25
|
updateDebugValue: (data: unknown) => void;
|
|
25
26
|
useDebugDataWatch: (target: unknown) => void;
|
|
26
27
|
};
|
package/lib/dreaction.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dreaction.d.ts","sourceRoot":"","sources":["../src/dreaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EAExB,UAAU,EACV,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAGpF,OAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAA0B,EACxB,wBAAwB,EACzB,MAAM,6BAA6B,CAAC;AACrC,OAAmB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAIrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,YAA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a,EAAE,CAAC;AAM9B,eAAO,MAAM,sBAAsB,OAOO,CAAC;AAE3C,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC;IAC5C,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC;IACvC,YAAY,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC;IAC7C,UAAU,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,KAAK,yBAAyB,GAAG,wBAAwB,CACvD,aAAa,EACb,OAAO,sBAAsB,CAC9B,CAAC;AAEF,MAAM,WAAW,qBACf,SAAQ,UAAU,EAEhB,yBAAyB;IAC3B,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAC1D,mBAAmB,CAAC,EAAE,kBAAkB,CAAC;IACzC,sBAAsB,EAAE,CAAC,YAAY,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACnE,mBAAmB,EAAE,CAAC,CAAC,GAAG,OAAO,EAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAC3B;QACH,iBAAiB,EAAE,CAAC,GAAG,SAAS,CAAC;QACjC,gBAAgB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;QAC1C,iBAAiB,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;KAC9C,CAAC;CACH;AAkFD,eAAO,MAAM,SAAS,uBAAgD,CAAC"}
|
package/lib/dreaction.js
CHANGED
|
@@ -116,14 +116,25 @@ exports.dreaction.setAsyncStorageHandler = (asyncStorage) => {
|
|
|
116
116
|
exports.dreaction.registerDataWatcher = (name, type) => {
|
|
117
117
|
if (!__DEV__) {
|
|
118
118
|
return {
|
|
119
|
+
currentDebugValue: undefined,
|
|
119
120
|
updateDebugValue: () => { },
|
|
120
121
|
useDebugDataWatch: () => { },
|
|
121
122
|
};
|
|
122
123
|
}
|
|
124
|
+
let prev = undefined;
|
|
123
125
|
const updateDebugValue = (data) => {
|
|
124
|
-
|
|
126
|
+
let newData = prev;
|
|
127
|
+
if (typeof data === 'function') {
|
|
128
|
+
newData = data(prev);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
newData = data;
|
|
132
|
+
}
|
|
133
|
+
prev = newData;
|
|
134
|
+
exports.dreaction.send('dataWatch', { name, type, data: newData });
|
|
125
135
|
};
|
|
126
136
|
return {
|
|
137
|
+
currentDebugValue: prev,
|
|
127
138
|
updateDebugValue,
|
|
128
139
|
useDebugDataWatch: (target) => {
|
|
129
140
|
(0, react_1.useEffect)(() => {
|
package/package.json
CHANGED
package/src/dreaction.ts
CHANGED
|
@@ -60,10 +60,11 @@ export interface ReactotronReactNative
|
|
|
60
60
|
useReactNative: (options?: UseReactNativeOptions) => this;
|
|
61
61
|
asyncStorageHandler?: AsyncStorageStatic;
|
|
62
62
|
setAsyncStorageHandler: (asyncStorage: AsyncStorageStatic) => this;
|
|
63
|
-
registerDataWatcher: (
|
|
63
|
+
registerDataWatcher: <T = unknown>(
|
|
64
64
|
name: string,
|
|
65
65
|
type: DataWatchPayload['type']
|
|
66
66
|
) => {
|
|
67
|
+
currentDebugValue: T | undefined;
|
|
67
68
|
updateDebugValue: (data: unknown) => void;
|
|
68
69
|
useDebugDataWatch: (target: unknown) => void;
|
|
69
70
|
};
|
|
@@ -195,24 +196,35 @@ dreaction.setAsyncStorageHandler = (asyncStorage: AsyncStorageStatic) => {
|
|
|
195
196
|
return dreaction;
|
|
196
197
|
};
|
|
197
198
|
|
|
198
|
-
dreaction.registerDataWatcher = (
|
|
199
|
+
dreaction.registerDataWatcher = <T = unknown>(
|
|
199
200
|
name: string,
|
|
200
201
|
type: DataWatchPayload['type']
|
|
201
202
|
) => {
|
|
202
203
|
if (!__DEV__) {
|
|
203
204
|
return {
|
|
205
|
+
currentDebugValue: undefined,
|
|
204
206
|
updateDebugValue: () => {},
|
|
205
207
|
useDebugDataWatch: () => {},
|
|
206
208
|
};
|
|
207
209
|
}
|
|
208
210
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
+
let prev: T | undefined = undefined;
|
|
212
|
+
|
|
213
|
+
const updateDebugValue = (data: T | ((prev: T | undefined) => T)) => {
|
|
214
|
+
let newData = prev;
|
|
215
|
+
if (typeof data === 'function') {
|
|
216
|
+
newData = (data as (prev: T | undefined) => T)(prev);
|
|
217
|
+
} else {
|
|
218
|
+
newData = data;
|
|
219
|
+
}
|
|
220
|
+
prev = newData;
|
|
221
|
+
dreaction.send('dataWatch', { name, type, data: newData });
|
|
211
222
|
};
|
|
212
223
|
|
|
213
224
|
return {
|
|
225
|
+
currentDebugValue: prev,
|
|
214
226
|
updateDebugValue,
|
|
215
|
-
useDebugDataWatch: (target:
|
|
227
|
+
useDebugDataWatch: (target: T) => {
|
|
216
228
|
useEffect(() => {
|
|
217
229
|
updateDebugValue(target);
|
|
218
230
|
}, [target]);
|