Skip to main content

ExternalService

Interface to an external service.

External services must be carefully managed in reactive Skip services to make sure that dependencies are properly tracked and data from external systems is kept up to date.

Context.useExternalResource accepts the name of an external service, which must be associated to an instance of this ExternalService interface by SkipService.externalServices.

There are two main implementations of ExternalService, depending on whether the external data source is a reactive Skip service or not.

If it is a Skip service, then SkipExternalService can be used, specifying an entrypoint. The external Skip service will update its resources reactively and those changes will propagate through this service.

If it is not a Skip service, then GenericExternalService and Polled can be used to specify the external source and desired polling frequency.

Methods

shutdown()

shutdown(): void

Shutdown the external service.

Returns

void


subscribe()

subscribe(
instance,
resource,
params,
callbacks): void

Subscribe to a resource provided by the external service.

Parameters

ParameterTypeDescription
instancestringInstance identifier of the external resource.
resourcestringName of the external resource.
paramsJsonParameters of the external resource.
callbacks{ error: (error) => void; loading: () => void; update: (updates, isInit) => void; }Callbacks to react on error/loading/update.
callbacks.error(error) => voidError callback.
callbacks.loading() => voidLoading callback.
callbacks.update(updates, isInit) => voidUpdate callback.

Returns

void


unsubscribe()

unsubscribe(instance): void

Unsubscribe from a resource provided by the external service.

Parameters

ParameterTypeDescription
instancestringInstance identifier of the external resource.

Returns

void