How to use the ember-app-scheduler.whenRouteIdle function in ember-app-scheduler

To help you get started, we’ve selected a few ember-app-scheduler examples, based on popular ways it is used in public projects.

github DockYard / ember-router-scroll / addon / index.js View on Github external
const delayScrollTop = get(this, 'service.delayScrollTop');
    const scrollWhenPainted = get(this, 'service.scrollWhenPainted');
    const scrollWhenIdle = get(this, 'service.scrollWhenIdle');

    if (!delayScrollTop && !scrollWhenPainted && !scrollWhenIdle) {
      // out of the 3 options, this happens on the tightest schedule
      scheduleOnce('render', this, () => this.updateScrollPosition(transition, true));
    } else if (scrollWhenPainted) {
      // as described in ember-app-scheduler, this addon can be used to delay rendering until after First Meaningful Paint.
      // If you loading your routes progressively, this may be a good option to delay scrollTop until the remaining DOM elements are painted.
      whenRoutePainted().then(() => {
        this.updateScrollPosition(transition);
      });
    } else {
      // as described in ember-app-scheduler, this addon can be used to delay rendering until after the route is idle
      whenRouteIdle().then(() => {
        this.updateScrollPosition(transition);
      });
    }
  }
});
github ember-app-scheduler / ember-app-scheduler / tests / dummy / app / components / when-route-idle.js View on Github external
init() {
    this._super(...arguments);
    this.set('whenRouteIdle', false);

    whenRouteIdle().then(() => {
      this.set('whenRouteIdle', true);
    });
  },
});

ember-app-scheduler

Ember addon to schedule work at different phases of app life cycle.

MIT
Latest version published 8 months ago

Package Health Score

70 / 100
Full package analysis

Similar packages