Skip to content

Documentation / @warp-drive/core / store / NotificationManager

Interface: NotificationManager

Defined in: core/src/store/-private/managers/notification-manager.ts:93

Hideconstructor

The NotificationManager provides the ability to subscribe to changes to Cache state.

This Feature is what allows WarpDrive to create subscriptions that work with any framework or change-notification system.

Methods

subscribe()

Call Signature

ts
subscribe(cacheKey, callback): object;

Defined in: core/src/store/-private/managers/notification-manager.ts:143

Subscribe to changes for a given ResourceKey, RequestKey, or addition/removal of any resource or document.

ts
export type CacheOperation = 'added' | 'removed' | 'updated' | 'state';

export interface NotificationCallback {
  (cacheKey: ResourceKey, notificationType: 'attributes' | 'relationships', key?: string): void;
  (cacheKey: ResourceKey, notificationType: 'errors' | 'meta' | 'identity' | 'state'): void;
  (cacheKey: ResourceKey, notificationType: NotificationType, key?: string): void;
}
export interface ResourceOperationCallback {
  // resource updates
  (cacheKey: ResourceKey, notificationType: CacheOperation): void;
}
export interface DocumentOperationCallback {
  // document updates
  (cacheKey: RequestKey, notificationType: CacheOperation): void;
}
Parameters
cacheKey

ResourceKey

callback

NotificationCallback

Returns

object

an opaque token to be used with unsubscribe

Call Signature

ts
subscribe(cacheKey, callback): object;

Defined in: core/src/store/-private/managers/notification-manager.ts:144

Subscribe to changes for a given ResourceKey, RequestKey, or addition/removal of any resource or document.

ts
export type CacheOperation = 'added' | 'removed' | 'updated' | 'state';

export interface NotificationCallback {
  (cacheKey: ResourceKey, notificationType: 'attributes' | 'relationships', key?: string): void;
  (cacheKey: ResourceKey, notificationType: 'errors' | 'meta' | 'identity' | 'state'): void;
  (cacheKey: ResourceKey, notificationType: NotificationType, key?: string): void;
}
export interface ResourceOperationCallback {
  // resource updates
  (cacheKey: ResourceKey, notificationType: CacheOperation): void;
}
export interface DocumentOperationCallback {
  // document updates
  (cacheKey: RequestKey, notificationType: CacheOperation): void;
}
Parameters
cacheKey

"resource"

callback

ResourceOperationCallback

Returns

object

an opaque token to be used with unsubscribe

Call Signature

ts
subscribe(cacheKey, callback): object;

Defined in: core/src/store/-private/managers/notification-manager.ts:145

Subscribe to changes for a given ResourceKey, RequestKey, or addition/removal of any resource or document.

ts
export type CacheOperation = 'added' | 'removed' | 'updated' | 'state';

export interface NotificationCallback {
  (cacheKey: ResourceKey, notificationType: 'attributes' | 'relationships', key?: string): void;
  (cacheKey: ResourceKey, notificationType: 'errors' | 'meta' | 'identity' | 'state'): void;
  (cacheKey: ResourceKey, notificationType: NotificationType, key?: string): void;
}
export interface ResourceOperationCallback {
  // resource updates
  (cacheKey: ResourceKey, notificationType: CacheOperation): void;
}
export interface DocumentOperationCallback {
  // document updates
  (cacheKey: RequestKey, notificationType: CacheOperation): void;
}
Parameters
cacheKey

"document" | RequestKey

callback

DocumentOperationCallback

Returns

object

an opaque token to be used with unsubscribe


unsubscribe()

ts
unsubscribe(token): void;

Defined in: core/src/store/-private/managers/notification-manager.ts:176

remove a previous subscription

Parameters

token

object

Returns

void

Released under the MIT License.