How to use the react-orbitjs.pushPayload function in react-orbitjs

To help you get started, we’ve selected a few react-orbitjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / data / orbitjs-operations-support / serialize-from-api.ts View on Github external
(data as JSONAPIOperationsPayload).operations.forEach((operation) => {
      let removedRecords = [];
      let transforms = [];

      let operationData;

      switch (operation.op) {
        case 'get':
        case 'update':
        case 'add':
          pushPayload(store, { ...operation });
          break;
        case 'remove':
          operationData = operation.data || operation.ref;
          removedRecords = Array.isArray(operationData) ? operationData : [operationData];

          removedRecords.forEach((record) => {
            let recordIdentity = recordIdentityFrom(
              store,
              record.id,
              toOrbitType(store, record.type)
            );
            // was this record already removed from the cache?
            // maybe we are receiving an operations payload that is telling us
            // to remove something that we've already removed.
            let exists = false;
github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / ui / routes / projects / show / overview / products / selection-manager / product-selection.tsx View on Github external
const pollCallback = useCallback(async () => {
    if (workflowProjectUrl) {
      return true;
    }

    try {
      const url = `projects/${idFromRecordIdentity(dataStore, project)}`;
      const response = await authenticatedGet(`/api/${url}`);
      const json = await response.json();

      await pushPayload(dataStore, json);

      const fromCache = dataStore.cache.query((q) => q.findRecord(project));

      const { workflowProjectUrl } = attributesFor(fromCache);

      return workflowProjectUrl;
    } catch (e) {
      return false;
    }
  }, [dataStore, project, workflowProjectUrl]);
github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / ui / components / cache-hydrater.tsx View on Github external
(async () => {
        const response = await fetch('/api/organizations', {
          headers: defaultHeaders(),
        });
        const json = await response.json();

        await pushPayload(dataStore, json);
        setNeedsSuperAdminData(false);
      })();
    }
github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / data / orbitjs-operations-support / serialize-from-api.ts View on Github external
export function dataToLocalCache(store: Store, data: JSONAPIOperationsPayload | JSONAPIDocument) {
  if ((data as JSONAPIDocument).data) {
    return pushPayload(store, data);
  }

  if ((data as JSONAPIOperationsPayload).operations) {
    (data as JSONAPIOperationsPayload).operations.forEach((operation) => {
      let removedRecords = [];
      let transforms = [];

      let operationData;

      switch (operation.op) {
        case 'get':
        case 'update':
        case 'add':
          pushPayload(store, { ...operation });
          break;
        case 'remove':