ember-tardy-params

The default blueprint for ember-cli addons.

Usage no npm install needed!

<script type="module">
  import emberTardyParams from 'https://cdn.skypack.dev/ember-tardy-params';
</script>

README

ember-tardy-params

Bind on-the-fly query parameters to your models

About

It is not possible to dynamically add new query parameters after the model hook has completed. This addon helps make it possible to manage individual model state in the URL. In our case, we needed to rely on models to manage map layers and layer state. We also wanted the presence of those layer models to handle the query parameters out-of-the-box.

This simple addon creates a new HistoryLocation object.

Usage

environment.js

locationType: 'tardy-params',

route.js

  // snip...

  model() {
    return this.store.findAll('map-layer');
  },

  afterModel({ models }, { queryParams }) {
    const tardyParams = getOwner(this).lookup('location:tardy-params');
    tardyParams.setupQueryParamModels(models, queryParams);
  }

  // snip...