Ember service for your query params
This addon is in response to https://github.com/emberjs/ember.js/issues/11592.
The idea came from Robert Jackson.
See the Changelog for version changes.
Basically the idea is that there is a central service that stores all QP valuesand from which you can subscribe to QP changes.
We make this simple by providing a mixin for your route that sets up default QPvalues on the service from your controller, and hooks into the system for QP changeson URL updates. The controller also gets automatic subscriptions for all of it's ownQPs.
You can also use the service yourself, i.e. paramsRelay: Ember.inject.service()
anywhereelse, and get access to setting, getting and subscribing to the QP changes.
Setup your route with the AutoSubscribe
mixin so we can listen for changesin query params from the URL, and also setup automatic subscribes for allof the query params on the related controller.
// my-route.js
import Route from '@ember/routing/route';
import AutosubscribeMixin from 'ember-query-params/mixins/autosubscribe';
export default Route.extend(AutosubscribeMixin, {
// If overriding `beforeModel`, make sure to call `this._super(...arguments)`.
// Whatever else you have..
});
The AutoSubscribe
mixin requires that your controller has queryParams
arraysetup to start relaying query params to the paramsRelay
service.
// my-controller.js
import Controller from '@ember/controller';
export default Controller.extend({
queryParams: [
'theme',
{ isSidebarOpen: 'sidebar' }
],
isSidebarOpen: false,
theme: 'default'
});
setParam
Function signature paramsRelay.setParam('name', value)
.
getParam
Function signature paramsRelay.getParam('name')
. Returns the value, can be anything.
setParams
Function signature paramsRelay.setParams(obj)
.
A helper method to set many query params at once. Suggested usage includesusing in the route, i.e. paramsRelay.setParams(this.paramsFor(this.routeName))
.
hasParams
Function signature paramsRelay.hasParams()
.
Returns a boolean, letting you know if any params have been set on the service.
subscribe
Function signature paramsRelay.subscribe('name', (key, value) => { //do something });
.
unsubscribe
Function signature paramsRelay.unsubscribe('name', sameFunctionUsedInSubscribe)
.The function you passed to subscribe
must be the same one passed to unsubscribe
to remove it fromthe list of callbacks to notify on change.
autoSubscribe
Function signature paramsRelay.autoSubscribe(this)
.
Where this
is the controller that has a queryParams
array.All default query param values from the controller are set on the paramsRelay
service.All query params must have a unique name, since setting a 'theme' in one controller will set the same QP in another.
You can also setup your own service, just use the mixin.
import Service from '@ember/service';
import QPMixin from 'ember-query-params/mixins/query-params';
export default Service.extend(QPMixin, {
// your code
});
See CONTRIBUTING.md.
Something about Ember Data Introduction Records A record is an instance of a model that contains data loaded from a server. Your application can also create new records and save them back to the serve
数据连接查询修改:op=fr_pm&cmd=pm_data_connect 版本信息:op=fr_server&cmd=sc_version_info&__showtoolbar__=false 该版本支持功能列表:op=fr_server&cmd=sc_functionlisthtml&__showtoolbar__=false 服务器当前访问情况:op=fr_server&cmd=sc_vis
emberjs/data Ember Data Ember Data is a library for loading models from a persistence layer (such as a JSON API), updating those models, then saving the changes. It provides many of the facilities you
Match All Query 最简单的查询,它匹配所有文档 查看 Match All Query QueryBuilder qb = matchAllQuery();
Query是一个抽象类,包含各种实用程序方法,是Lucene在搜索过程中使用的所有类型查询的父级。 Class 声明 (Class Declaration) 以下是org.apache.lucene.search.Query类的声明 - public abstract class Query extends Object implements Serializable, Clon
Every GraphQL schema has a root type for both queries and mutations. The query type defines GraphQL operations that retrieve data from the server. Fieldsaction (Action) 动作查询接口 Argument Type Descriptio
本文向大家介绍coldfusion Query,包括了coldfusion Query的使用技巧和注意事项,需要的朋友参考一下 示例 考虑表dbo.state_zip,其中包含列city,statecode并且zipcode,有超过80,000条记录。 参数 属性 需要 类型 默认 描述 询问 真正 串 查询对象的变量名。 起始行 假 数字 查询对象的起始行索引。 row 假 数字 查询对象的结束
Gathers nested Element objects matching the given set of CSS selectors Parameters querystringCSS selector Returns: Set array result of query selection
Gathers the nested Element matching the given set of CSS selectors Parameters querystringCSS selector Returns: Element result of query selection