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


      // 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:
      // Until then:
      var modelRegexp = /^[a-zA-Z0-9-_]+\/models\/(.*)$/;
      var modelNames = new ModuleRegistry()
        .filter((name) => modelRegexp.test(name))
        .map((name) => modelRegexp.exec(name)[1]);
      // Check for models in any pending state. Inspired by:
      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) =>
 => r.get(s)).some((i) => i)
        allPendingRecords =  allPendingRecords.concat(pendingRecords);