-
Notifications
You must be signed in to change notification settings - Fork 25
/
pageable-subscriber-mixin.js
33 lines (26 loc) · 1.09 KB
/
pageable-subscriber-mixin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { EventSubscriberController, IdSubscriberController } from '../../controllers/subscriber/subscriberControllers.js';
export const PageableSubscriberMixin = superclass => class extends superclass {
static get properties() {
return {
/**
* Id of the `PageableMixin` component this component wants to observe (if not located within that component)
* @type {string}
*/
pageableFor: { type: String, reflect: true, attribute: 'pageable-for' },
_pageableInfo: { state: true }
};
}
constructor() {
super();
this._pageableInfo = null;
this._pageableEventSubscriber = new EventSubscriberController(this, 'pageable');
this._pageableIdSubscriber = new IdSubscriberController(this, 'pageable', { idPropertyName: 'pageableFor' });
}
async getUpdateComplete() {
await super.getUpdateComplete();
await (this.pageableFor ? this._pageableIdSubscriber._subscriptionComplete : this._pageableEventSubscriber._subscriptionComplete);
}
_getPageableRegistries() {
return this.pageableFor ? this._pageableIdSubscriber.registries : [ this._pageableEventSubscriber.registry ];
}
};