@uxland-admin/ip-context-info
Advanced tools
Comparing version 1.0.8 to 1.0.9
import isAsyncStateStale from "@uxland/uxl-redux/is-async-stale"; | ||
import { FETCH_CONTEXT_INFO } from "../../state/context-info/reducer"; | ||
import { store } from '@uxland/uxl-prism/store'; | ||
import { createAsyncActions } from "@uxland/uxl-redux/create-async-actions"; | ||
import { icsFetchClient } from "@uxland-admin/ics-process-core/ics-fetch-client"; | ||
import { patientContextSelector } from "@uxland-admin/ics-process-core/patient-context/patient-context-selector"; | ||
import { contextInfoSelector } from "./context-info-view"; | ||
export const asyncAction = async (action, fn, store, meta) => { | ||
let started = window.performance.now(); | ||
let actions = createAsyncActions(action); | ||
try { | ||
store.dispatch({ type: actions.started, meta: meta }); | ||
let result = await fn(); | ||
store.dispatch({ type: actions.succeeded, payload: result, meta: meta }); | ||
} | ||
catch (e) { | ||
store.dispatch({ type: actions.failed, payload: e, meta: meta }); | ||
} | ||
finally { | ||
store.dispatch({ type: actions.ended, payload: { elapsed: window.performance.now() - started }, meta: meta }); | ||
} | ||
}; | ||
import { performAsyncAction } from '@uxland/uxl-redux/perform-async-action'; | ||
export const fetchContextInfo = () => { | ||
@@ -29,5 +14,5 @@ let patientContext = patientContextSelector(store.getState()); | ||
let uri = `/patient/${patientContext.center}/${patientContext.patient}/${patientContext.case}/${patientContext.movement}/context-info`; | ||
return asyncAction(FETCH_CONTEXT_INFO, () => icsFetchClient.fetch(uri), store); | ||
return performAsyncAction(FETCH_CONTEXT_INFO, () => icsFetchClient.fetch(uri), store); | ||
} | ||
} | ||
}; |
@@ -88,5 +88,3 @@ declare module '@uxland-admin/ip-context-info/constants' { | ||
declare module '@uxland-admin/ip-context-info/app/context-info/fetch-context-info' { | ||
import { Store } from "redux"; | ||
export const asyncAction: <T = any>(action: string, fn: () => Promise<T>, store: Store<any, import("redux").AnyAction>, meta?: any) => Promise<void>; | ||
export const fetchContextInfo: () => Promise<void>; | ||
export const fetchContextInfo: () => Promise<any>; | ||
@@ -93,0 +91,0 @@ } |
{ | ||
"name": "@uxland-admin/ip-context-info", | ||
"description": "ICS Process - Context info", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22875
397