Clean up
This commit is contained in:
@@ -17,9 +17,8 @@ const dataProvider = ({ dataModels, getSession }: DataProviderConfig) : DataProv
|
||||
},
|
||||
create: async ({ resource, variables, meta }) => {
|
||||
console.log("create", resource, variables, meta);
|
||||
|
||||
|
||||
const session = getSession();
|
||||
console.log('session', session);
|
||||
|
||||
const docNuri = await ng.doc_create(
|
||||
session!.session_id,
|
||||
@@ -93,12 +92,6 @@ const dataProvider = ({ dataModels, getSession }: DataProviderConfig) : DataProv
|
||||
}
|
||||
},
|
||||
getApiUrl: () => "",
|
||||
// optional methods
|
||||
// getMany: ({ resource, ids, meta }) => Promise,
|
||||
// createMany: ({ resource, variables, meta }) => Promise,
|
||||
// deleteMany: ({ resource, ids, variables, meta }) => Promise,
|
||||
// updateMany: ({ resource, ids, variables, meta }) => Promise,
|
||||
// custom: ({ url, method, filters, sorters, payload, query, headers, meta }) => Promise,
|
||||
});
|
||||
|
||||
export default dataProvider;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { LiveProvider } from "@refinedev/core";
|
||||
import { watch } from "@ng-org/alien-deepsignals"
|
||||
import { getSignalObject } from "./utils";
|
||||
import { parsePatches } from "./utils";
|
||||
import { getSignalObject, parsePatches } from "./utils";
|
||||
import { LiveProviderConfig, UnwatchFn } from "./types";
|
||||
|
||||
const liveProvider = ({ dataModels }: LiveProviderConfig) : LiveProvider => ({
|
||||
@@ -40,8 +39,6 @@ const liveProvider = ({ dataModels }: LiveProviderConfig) : LiveProvider => ({
|
||||
// We don't close the subscription because we want to keep listening for changes
|
||||
const set = await getSignalObject(dataModels[resource].shapeType, undefined, false);
|
||||
|
||||
console.log('set listening list', set);
|
||||
|
||||
const { stopListening } = watch(set, ({ newValue, patches }) => {
|
||||
console.log('objects list modified', newValue, patches);
|
||||
|
||||
@@ -65,7 +62,7 @@ const liveProvider = ({ dataModels }: LiveProviderConfig) : LiveProvider => ({
|
||||
return () => undefined;
|
||||
},
|
||||
unsubscribe: async (unwatchFn: UnwatchFn | Promise<UnwatchFn>) => {
|
||||
console.log('unsubscribe', typeof unwatchFn, unwatchFn);
|
||||
console.log('unsubscribe', unwatchFn);
|
||||
const fn = await Promise.resolve(unwatchFn);
|
||||
if (typeof fn === "function") {
|
||||
fn();
|
||||
|
||||
@@ -11,6 +11,7 @@ export const getSignalObject = async (shapeType: ShapeType<any>, ids?: string[],
|
||||
return signalObject;
|
||||
}
|
||||
|
||||
// Return true if the key is a valid graph key (not a document)
|
||||
export const isGraphKey = (key: BaseKey): boolean => {
|
||||
return key !== null && typeof key === "string" && key.includes(":v:");
|
||||
}
|
||||
@@ -22,6 +23,10 @@ export const addIdToObject = (obj: any) => {
|
||||
return { id: obj["@graph"], ...obj };
|
||||
};
|
||||
|
||||
/**
|
||||
* Takes a list of patches (returned by the watch function) and returns a record of modified IDs
|
||||
* with their corresponding event types (created, updated, deleted).
|
||||
*/
|
||||
export const parsePatches = (patches: DeepPatch[]) => {
|
||||
let modifiedIds : Record<string, 'created' | 'updated' | 'deleted'> = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user