@legendapp/state 3.0.0-beta.27 → 3.0.0-beta.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/state",
3
- "version": "3.0.0-beta.27",
3
+ "version": "3.0.0-beta.28",
4
4
  "description": "legend-state",
5
5
  "sideEffects": false,
6
6
  "private": false,
@@ -50,6 +50,9 @@ interface KeelClient {
50
50
  api: {
51
51
  queries: Record<string, (i: any) => Promise<any>>;
52
52
  };
53
+ client: {
54
+ rawRequest: <T>(action: string, body: any) => Promise<APIResult<T>>;
55
+ };
53
56
  }
54
57
  interface SyncedKeelPropsManyBase<TRemote extends {
55
58
  id: string;
@@ -50,6 +50,9 @@ interface KeelClient {
50
50
  api: {
51
51
  queries: Record<string, (i: any) => Promise<any>>;
52
52
  };
53
+ client: {
54
+ rawRequest: <T>(action: string, body: any) => Promise<APIResult<T>>;
55
+ };
53
56
  }
54
57
  interface SyncedKeelPropsManyBase<TRemote extends {
55
58
  id: string;
@@ -79,19 +79,16 @@ function setupRealtime(props) {
79
79
  const { client } = props;
80
80
  if (client && !modifiedClients.has(client)) {
81
81
  modifiedClients.add(client);
82
- const queries = client.api.queries;
83
- Object.keys(queries).forEach((key) => {
84
- if (key.startsWith("list")) {
85
- const origFn = queries[key];
86
- queries[key] = (i) => {
87
- realtimeState.current = {
88
- lastAction: key,
89
- lastParams: i
90
- };
91
- return origFn(i);
82
+ const originalRawRequest = client.client.rawRequest;
83
+ client.client.rawRequest = (action, body) => {
84
+ if (action.startsWith("list")) {
85
+ realtimeState.current = {
86
+ lastAction: action,
87
+ lastParams: body
92
88
  };
93
89
  }
94
- });
90
+ return originalRawRequest(action, body);
91
+ };
95
92
  }
96
93
  }
97
94
  var NumPerPage = 200;
@@ -77,19 +77,16 @@ function setupRealtime(props) {
77
77
  const { client } = props;
78
78
  if (client && !modifiedClients.has(client)) {
79
79
  modifiedClients.add(client);
80
- const queries = client.api.queries;
81
- Object.keys(queries).forEach((key) => {
82
- if (key.startsWith("list")) {
83
- const origFn = queries[key];
84
- queries[key] = (i) => {
85
- realtimeState.current = {
86
- lastAction: key,
87
- lastParams: i
88
- };
89
- return origFn(i);
80
+ const originalRawRequest = client.client.rawRequest;
81
+ client.client.rawRequest = (action, body) => {
82
+ if (action.startsWith("list")) {
83
+ realtimeState.current = {
84
+ lastAction: action,
85
+ lastParams: body
90
86
  };
91
87
  }
92
- });
88
+ return originalRawRequest(action, body);
89
+ };
93
90
  }
94
91
  }
95
92
  var NumPerPage = 200;