How to use the ember-resolver/utils/module-registry function in ember-resolver

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

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gabrielgrant / ember-cli-test-model-waiter / addon / instance-initializers / test-model-waiter.js View on Github external
Ember.Test.registerWaiter(function(){

      iterations++;

      // Get all models from the store
      // The following should work to get model names:
      //   var debugAdapter = appInstance.lookup('container-debug-adapter:main');
      //   debugAdapter.catalogEntriesByType('model');
      // but unfortunately it is buggy. Use that once the issue is fixed:
      // https://github.com/ember-cli/ember-resolver/issues/120
      // Until then:
      var modelRegexp = /^[a-zA-Z0-9-_]+\/models\/(.*)$/;
      var modelNames = new ModuleRegistry()
        .moduleNames()
        .filter((name) => modelRegexp.test(name))
        .map((name) => modelRegexp.exec(name)[1]);
      // Check for models in any pending state. Inspired by:
      // https://gist.github.com/rsutphin/73fdad14a24884eee336
      var store = appInstance.lookup('service:store');
      var pendingStates = ['isSaving','isEmpty', 'isLoading', 'isReloading'];
      var allPendingRecords = [];
      modelNames.forEach((name) => {
        var records = store.peekAll(name);
        var pendingRecords = records.filter((r) =>
          pendingStates.map((s) => r.get(s)).some((i) => i)
        );
        allPendingRecords =  allPendingRecords.concat(pendingRecords);
      });

ember-resolver

The default modules based resolver for Ember CLI.

MIT
Latest version published 1 month ago

Package Health Score

83 / 100
Full package analysis

Similar packages