dreaction-react-native 1.2.0 → 1.3.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.
@@ -52,10 +52,10 @@ exports.DraggableBall = react_1.default.memo(() => {
52
52
  const lastPosition = (0, react_1.useRef)(initialPosition);
53
53
  const [isDragging, setIsDragging] = (0, react_1.useState)(false);
54
54
  const [modalVisible, setModalVisible] = (0, react_1.useState)(false);
55
- const [connected, setConnected] = (0, react_1.useState)(false);
55
+ const [isReady, setIsReady] = (0, react_1.useState)(false);
56
56
  (0, react_1.useEffect)(() => {
57
57
  const timer = setInterval(() => {
58
- setConnected(dreaction_1.dreaction.connected);
58
+ setIsReady(dreaction_1.dreaction.isReady);
59
59
  }, 1000);
60
60
  return () => {
61
61
  clearInterval(timer);
@@ -121,7 +121,7 @@ exports.DraggableBall = react_1.default.memo(() => {
121
121
  {
122
122
  transform: [{ translateX: position.x }, { translateY: position.y }],
123
123
  backgroundColor: isDragging ? '#eee' : '#fff',
124
- borderColor: connected ? '#00ff00' : '#eee',
124
+ borderColor: isReady ? '#00ff00' : '#eee',
125
125
  },
126
126
  ], ...panResponder.panHandlers, children: (0, jsx_runtime_1.jsx)(react_native_1.Image, { style: styles.icon, source: require('../../assets/icon.png') }) }), (0, jsx_runtime_1.jsx)(ConfigDialog_1.ConfigDialog, { visible: modalVisible, onCancel: () => setModalVisible(false), onConfirm: handleClick })] }));
127
127
  });
package/lib/dreaction.js CHANGED
@@ -113,8 +113,9 @@ exports.dreaction.setAsyncStorageHandler = (asyncStorage) => {
113
113
  exports.dreaction.asyncStorageHandler = asyncStorage;
114
114
  return exports.dreaction;
115
115
  };
116
- exports.dreaction.registerDataWatcher = (name, type) => {
117
- if (!__DEV__) {
116
+ exports.dreaction.registerDataWatcher = (name, type, options) => {
117
+ const { enabled = __DEV__ } = options ?? {};
118
+ if (!enabled) {
118
119
  return {
119
120
  currentDebugValue: undefined,
120
121
  updateDebugValue: () => { },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dreaction-react-native",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "main": "lib/index.js",
@@ -15,7 +15,7 @@
15
15
  "author": "moonrailgun <moonrailgun@gmail.com>",
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
- "dreaction-client-core": "1.1.0",
18
+ "dreaction-client-core": "1.1.1",
19
19
  "dreaction-protocol": "1.0.0"
20
20
  },
21
21
  "devDependencies": {
@@ -25,11 +25,11 @@ export const DraggableBall: React.FC = React.memo(() => {
25
25
  const lastPosition = useRef(initialPosition);
26
26
  const [isDragging, setIsDragging] = useState(false);
27
27
  const [modalVisible, setModalVisible] = useState(false);
28
- const [connected, setConnected] = useState(false);
28
+ const [isReady, setIsReady] = useState(false);
29
29
 
30
30
  useEffect(() => {
31
31
  const timer = setInterval(() => {
32
- setConnected(dreaction.connected);
32
+ setIsReady(dreaction.isReady);
33
33
  }, 1000);
34
34
 
35
35
  return () => {
@@ -113,7 +113,7 @@ export const DraggableBall: React.FC = React.memo(() => {
113
113
  {
114
114
  transform: [{ translateX: position.x }, { translateY: position.y }],
115
115
  backgroundColor: isDragging ? '#eee' : '#fff',
116
- borderColor: connected ? '#00ff00' : '#eee',
116
+ borderColor: isReady ? '#00ff00' : '#eee',
117
117
  },
118
118
  ]}
119
119
  {...panResponder.panHandlers}
package/src/dreaction.ts CHANGED
@@ -198,9 +198,16 @@ dreaction.setAsyncStorageHandler = (asyncStorage: AsyncStorageStatic) => {
198
198
 
199
199
  dreaction.registerDataWatcher = <T = unknown>(
200
200
  name: string,
201
- type: DataWatchPayload['type']
201
+ type: DataWatchPayload['type'],
202
+ options?: {
203
+ /**
204
+ * Is data watcher enabled?
205
+ */
206
+ enabled?: boolean;
207
+ }
202
208
  ) => {
203
- if (!__DEV__) {
209
+ const { enabled = __DEV__ } = options ?? {};
210
+ if (!enabled) {
204
211
  return {
205
212
  currentDebugValue: undefined,
206
213
  updateDebugValue: () => {},