From d3eeb241eadb380af705e42281a7166f77d5a2ec Mon Sep 17 00:00:00 2001 From: Ilya Radchenko Date: Fri, 8 Apr 2016 11:37:38 -0400 Subject: [PATCH] Add docs for autosubscribe mixin --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 0accb3e..79141f6 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,25 @@ The idea came from [Robert Jackson]. ## Usage +```js +import Ember from 'ember'; +import AutosubscribeMixin from 'ember-query-params/mixins/autosubscribe'; + +export default Ember.Controller.extend(AutosubscribeMixin, { + queryParams: [ + 'theme', + { isSidebarOpen: 'sidebar' } + ], + isSidebarOpen: false, + theme: 'default' +}); +``` + +This will use `paramsRelay.autoSubscribe(controller)` on `init` and later +tear down on `willDestroy`. You also get a couple proxy methods, `subscribeParam` and +`unsubscribeParam` which work the same as the equivalent methods on the service. +Or you can use the service directly for maximum control. + ```js import Ember from 'ember';