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
Methods
notify
(
Boolean
private
-
identifier
-
value
-
key
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
(
UnsubscribeToken
public
-
identifier
-
callback
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
(
public
-
token
remove a previous subscription
Parameters:
-
token
UnsubscribeToken