Opened 10 years ago
Closed 5 years ago
#13212 closed enhancement (patchwelcome)
Add delete and forEach to dojo.Stateful
Reported by: | nvd_ai61 | Owned by: | Kitson Kelly |
---|---|---|---|
Priority: | low | Milestone: | 1.11 |
Component: | Core | Version: | 1.7.0b1 |
Keywords: | Stateful watch | Cc: | |
Blocked By: | Blocking: |
Description
Dojo.Stateful is useful for implementing MVC architectures, to connect the model to the view. But, IMO, two features are missing:
1-Deletion: it should be possible to delete a property from a stateful object and be notified. Say, I have a list of products in my model and a dijit widget is showing them in the browser. When an item is deleted from the model, the widget should be notified and remove that item from the UI. At the moment, there is no API to delete a property from the stateful object. If I remove one property directly, it won't trigger the watch callback. The closest solution is to set the property to null and consider null as deleted. But it is a dirty solution as anytime I want to retrieve an item, I have to test its value against null to make sure it is not a deleted item.
2-Iteration over the properties: I assume I can iterate over dojo.Stateful object but it returns postscript, set, get, and watch functions as the properties of the object. These functions should be hidden from the iterator. A forEach function can be implemented to hide these functions.
Change History (4)
comment:1 Changed 10 years ago by
Component: | General → Core |
---|---|
Owner: | set to Kris Zyp |
comment:2 Changed 8 years ago by
Milestone: | tbd → future |
---|---|
Owner: | changed from Kris Zyp to Kitson Kelly |
Status: | new → assigned |
comment:3 Changed 8 years ago by
Priority: | high → low |
---|
comment:4 Changed 5 years ago by
Milestone: | future → 1.11 |
---|---|
Resolution: | → patchwelcome |
Status: | assigned → closed |
Closing as patchwelcome. A solution will exist for Dojo 2, but with Object.observe being deprecated, things will change.
The first one would be possible.
The second one would be more challenging. While a forEach could be implemented, using ES5 property descriptors would be a preferred way of doing this instead of tacking on more sugar to Stateful.
Either way, they will like not be addressed in Dojo 1.X and will have to wait for Dojo 2, where we are more likely to follow the Harmony ES5 Object.observe structure.