{"id":15383675,"url":"https://github.com/knownasilya/ember-query-params","last_synced_at":"2025-04-13T09:06:46.290Z","repository":{"id":6926196,"uuid":"55719965","full_name":"knownasilya/ember-query-params","owner":"knownasilya","description":"Ember service for your query params","archived":false,"fork":false,"pushed_at":"2022-12-10T19:02:21.000Z","size":555,"stargazers_count":44,"open_issues_count":24,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T09:06:40.857Z","etag":null,"topics":["ember","ember-addon","query-params"],"latest_commit_sha":null,"homepage":"http://knownasilya.github.io/ember-query-params/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/knownasilya.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-07T18:55:33.000Z","updated_at":"2024-05-30T02:28:51.000Z","dependencies_parsed_at":"2023-01-13T14:10:51.414Z","dependency_job_id":null,"html_url":"https://github.com/knownasilya/ember-query-params","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knownasilya%2Fember-query-params","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knownasilya%2Fember-query-params/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knownasilya%2Fember-query-params/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knownasilya%2Fember-query-params/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knownasilya","download_url":"https://codeload.github.com/knownasilya/ember-query-params/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248688570,"owners_count":21145766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ember","ember-addon","query-params"],"created_at":"2024-10-01T14:39:07.238Z","updated_at":"2025-04-13T09:06:46.265Z","avatar_url":"https://github.com/knownasilya.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ember-query-params\n\nEmber service for your query params\n\n:construction: Please use [ember-parachute] or [ember-query-params-service] instead.\n\n[![NPM][npm-badge-img]][npm-badge-link]\n[![Build Status][travis-badge]][travis-badge-url]\n[![Ember Observer Score][ember-observer-badge]][ember-observer-url]\n![Ember Version][ember-version]\n\nThis addon is in response to https://github.com/emberjs/ember.js/issues/11592.  \nThe idea came from [Robert Jackson].\n\nSee the [Changelog] for version changes.\n\n## Compatibility\n\n* Ember.js v2.18 or above\n* Ember CLI v2.13 or above\n* Node.js v8 or above\n\n\n## How It Works\n\nBasically the idea is that there is a central service that stores all QP values\nand from which you can subscribe to QP changes.\n\nWe make this simple by providing a mixin for your route that sets up default QP\nvalues on the service from your controller, and hooks into the system for QP changes\non URL updates. The controller also gets automatic subscriptions for all of it's own\nQPs.\n\nYou can also use the service yourself, i.e. `paramsRelay: Ember.inject.service()` anywhere\nelse, and get access to setting, getting and subscribing to the QP changes.\n\n\n## Usage\n\nSetup your route with the `AutoSubscribe` mixin so we can listen for changes\nin query params from the URL, and also setup automatic subscribes for all\nof the query params on the related controller.\n\n```js\n// my-route.js\nimport Route from '@ember/routing/route';\nimport AutosubscribeMixin from 'ember-query-params/mixins/autosubscribe';\n\nexport default Route.extend(AutosubscribeMixin, {\n  // If overriding `beforeModel`, make sure to call `this._super(...arguments)`.\n  // Whatever else you have..\n});\n```\n\nThe `AutoSubscribe` mixin requires that your controller has `queryParams` array\nsetup to start relaying query params to the `paramsRelay` service.\n\n```js\n// my-controller.js\nimport Controller from '@ember/controller';\n\nexport default Controller.extend({\n  queryParams: [\n    'theme',\n    { isSidebarOpen: 'sidebar' }\n  ],\n  isSidebarOpen: false,\n  theme: 'default'\n});\n```\n\n\n## Service API\n\n#### `setParam`\n\nFunction signature `paramsRelay.setParam('name', value)`.\n\n#### `getParam`\n\nFunction signature `paramsRelay.getParam('name')`. Returns the value, can be anything.\n\n#### `setParams`\n\nFunction signature `paramsRelay.setParams(obj)`.  \nA helper method to set many query params at once. Suggested usage includes\nusing in the route, i.e. `paramsRelay.setParams(this.paramsFor(this.routeName))`.\n\n#### `hasParams`\n\nFunction signature `paramsRelay.hasParams()`.  \nReturns a boolean, letting you know if any params have been set on the service.\n\n#### `subscribe`\n\nFunction signature `paramsRelay.subscribe('name', (key, value) =\u003e { //do something });`.\n\n#### `unsubscribe`\n\nFunction signature `paramsRelay.unsubscribe('name', sameFunctionUsedInSubscribe)`.\nThe function you passed to `subscribe` must be the same one passed to `unsubscribe` to remove it from\nthe list of callbacks to notify on change.\n\n#### `autoSubscribe`\n\nFunction signature `paramsRelay.autoSubscribe(this)`.  \nWhere `this` is the controller that has a `queryParams` array.\nAll default query param values from the controller are set on the `paramsRelay` service.\nAll query params must have a unique name, since setting a 'theme' in one controller will set the same QP in another.\n\n\n## Custom Service\n\nYou can also setup your own service, just use the mixin.\n\n```js\nimport Service from '@ember/service';\nimport QPMixin from 'ember-query-params/mixins/query-params';\n\nexport default Service.extend(QPMixin, {\n  // your code\n});\n```\n\n## Contributing\n\nSee [CONTRIBUTING.md].\n\n[ember-parachute]: https://github.com/offirgolan/ember-parachute\n[ember-query-params-service]: https://github.com/NullVoxPopuli/ember-query-params-service\n[npm-badge-img]: https://badge.fury.io/js/ember-query-params.svg\n[npm-badge-link]: http://badge.fury.io/js/ember-query-params\n[travis-badge]: https://travis-ci.org/knownasilya/ember-query-params.svg\n[travis-badge-url]: https://travis-ci.org/knownasilya/ember-query-params\n[ember-observer-badge]: http://emberobserver.com/badges/ember-query-params.svg\n[ember-observer-url]: http://emberobserver.com/addons/ember-query-params\n[ember-version]: https://embadge.io/v1/badge.svg?start=1.13.0\n[Robert Jackson]: https://github.com/rwjblue\n[polyfill]: https://github.com/babel/ember-cli-babel#polyfill\n[CONTRIBUTING.md]: CONTRIBUTING.md\n[Changelog]: CHANGELOG.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknownasilya%2Fember-query-params","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknownasilya%2Fember-query-params","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknownasilya%2Fember-query-params/lists"}