API Docs for: 5.4.0-alpha.19+09702cf1
Show:

NotificationManager Class

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

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

Item Index

Methods

notify

(
  • identifier
  • value
  • key
)
Boolean private

Custom Caches and Application Code should not call this method directly.

Parameters:

  • identifier Object
  • value Object
  • key Object

Returns:

Boolean:

whether a notification was delivered to any subscribers

subscribe

(
  • identifier
  • callback
)
UnsubscribeToken public

Subscribe to changes for a given resource identifier, resource addition/removal, or document addition/removal.

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

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

Parameters:

  • identifier StableDocumentIdentifier | StableRecordIdentifier | 'resource' | 'document'
  • callback NotificationCallback | ResourceOperationCallback | DocumentOperationCallback

Returns:

UnsubscribeToken:

an opaque token to be used with unsubscribe

unsubscribe

(
  • token
)
public

remove a previous subscription

Parameters:

  • token UnsubscribeToken