How to use the datx.setModelMetaKey function in datx

To help you get started, we’ve selected a few datx 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 infinum / datx / packages / datx-jsonapi / src / NetworkUtils.ts View on Github external
throw response.error;
    }

    if (response.status === 204) {
      setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);

      return record;
    } else if (response.status === 202) {
      const responseRecord = response.data as T;
      setModelMetaKey(responseRecord, MODEL_PROP_FIELD, prop);
      setModelMetaKey(responseRecord, MODEL_QUEUE_FIELD, true);
      setModelMetaKey(responseRecord, MODEL_RELATED_FIELD, record);

      return responseRecord;
    } else {
      setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);

      return response.replaceData(record).data as T;
    }
  });
}
github infinum / datx / packages / datx-jsonapi / src / NetworkUtils.ts View on Github external
return action((response: LibResponse): T => {
    if (response.error) {
      throw response.error;
    }

    if (response.status === 204) {
      setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);

      return record;
    } else if (response.status === 202) {
      const responseRecord = response.data as T;
      setModelMetaKey(responseRecord, MODEL_PROP_FIELD, prop);
      setModelMetaKey(responseRecord, MODEL_QUEUE_FIELD, true);
      setModelMetaKey(responseRecord, MODEL_RELATED_FIELD, record);

      return responseRecord;
    } else {
      setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);

      return response.replaceData(record).data as T;
    }
  });
}
github infinum / datx / packages / datx-jsonapi / src / helpers / model.ts View on Github external
return responseObj.then((response) => {
      const related = getModelMetaKey(model, MODEL_RELATED_FIELD);
      const prop = getModelMetaKey(model, MODEL_PROP_FIELD);
      const record = response.data;
      const recordType = record && getModelType(record);
      if (record && recordType !== getModelType(model) && recordType === getModelType(related)) {
        if (prop) {
          related[prop] = record;

          return response;
        }
        setModelMetaKey(related, MODEL_PERSISTED_FIELD, true);

        return response.replaceData(related);
      }

      return response;
    });
  }
github infinum / datx / packages / datx-jsonapi / src / NetworkUtils.ts View on Github external
return action((response: LibResponse): T => {
    if (response.error) {
      throw response.error;
    }

    if (response.status === 204) {
      setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);

      return record;
    } else if (response.status === 202) {
      const responseRecord = response.data as T;
      setModelMetaKey(responseRecord, MODEL_PROP_FIELD, prop);
      setModelMetaKey(responseRecord, MODEL_QUEUE_FIELD, true);
      setModelMetaKey(responseRecord, MODEL_RELATED_FIELD, record);

      return responseRecord;
    } else {
      setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);

      return response.replaceData(record).data as T;
    }
  });
}
github infinum / datx / packages / datx-jsonapi / src / NetworkUtils.ts View on Github external
return action((response: LibResponse): T => {
    if (response.error) {
      throw response.error;
    }

    if (response.status === 204) {
      setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);

      return record;
    } else if (response.status === 202) {
      const responseRecord = response.data as T;
      setModelMetaKey(responseRecord, MODEL_PROP_FIELD, prop);
      setModelMetaKey(responseRecord, MODEL_QUEUE_FIELD, true);
      setModelMetaKey(responseRecord, MODEL_RELATED_FIELD, record);

      return responseRecord;
    } else {
      setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);

      return response.replaceData(record).data as T;
    }
  });
}
github infinum / datx / packages / datx-jsonapi / src / helpers / model.ts View on Github external
function setModelPersisted(model: PureModel, status: boolean) {
  setModelMetaKey(model, MODEL_PERSISTED_FIELD, status);
}