You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've a tableview for a list of objects that are returned from an url like /resource.
In the same view there is a filter to get only a part of these object using a url like /resource?filterByDate=2015-12-18.
In the Siesta withParam documentation there is a statement about the uniqueness of the Resource given from its full URL.
In this way I need to add an observer (the view, self), to a new Resource, every time the user select a different filter for the list.
Is there a way to observe a resource and, automatically, all its "withParams" variants? Something like myResource.observeAllParams(self).
I've seen the source but I didn't find an easy way to implement this.
The text was updated successfully, but these errors were encountered:
If two things are the same resource, then they must have the same data. Thus you definitely want /resource and /resource?filterByDate=2015-12-18 to be different resources: “all the things” and “things from Dec 18” are different pieces of information. It’s best to think of them as entirely separate resources.
In this way I need to add an observer (the view, self), to a new Resource, every time the user select a different filter for the list.
Yes, that’s exactly right.
In fact, it’s best not just to add the observers to the new resource, but to remove the old one as well. Think of your table view as always showing some particular resource, and when you change filters, you change which resource it’s showing: “Now show all the things!” “Now show things from Dec 18!”
The idiom that keeps this clean is to create a “currently displayed resource” property with a setter that un-observers the old resources and starts observing the new one. Take a look at this code from the example project, which shows how to integrate this behavior with a table view:
I've a tableview for a list of objects that are returned from an url like
/resource
.In the same view there is a filter to get only a part of these object using a url like
/resource?filterByDate=2015-12-18
.In the Siesta
withParam
documentation there is a statement about the uniqueness of the Resource given from its full URL.In this way I need to add an observer (the view,
self
), to a new Resource, every time the user select a different filter for the list.Is there a way to observe a resource and, automatically, all its "withParams" variants? Something like
myResource.observeAllParams(self)
.I've seen the source but I didn't find an easy way to implement this.
The text was updated successfully, but these errors were encountered: