[ALOY-1000] Model Binding a View generates multiple calls to update the data of bound objects.
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-05-28T16:06:53.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Alloy 1.5.0 |
Components | n/a |
Labels | qe-manualtest |
Reporter | Bert Grantges |
Assignee | Feon Sua Xin Miao |
Created | 2014-05-01T03:02:10.000+0000 |
Updated | 2014-08-22T23:27:48.000+0000 |
Description
I have a simple view that creates a Model instance and binds the model properties to two labels. Code samples are here: https://gist.github.com/grantges/28241878e3886c1cec51 When looking at the compiled JavaScript, you'll notice that the generated function to update the text properties on the bound Labels is being called twice. Expectation It should only be called once per label/propertyComments
- Tim Poulsen 2014-05-13 [~fmiao] would you confirm this is still happening with Alloy 1.4? Thanks.
- Feon Sua Xin Miao 2014-05-26 [~skypanther] it's still happening with Alloy 1.4.0-alpha4.
- Feon Sua Xin Miao 2014-05-27
PR: https://github.com/appcelerator/alloy/pull/418
Test app: https://github.com/feons/alloy/tree/ALOY-1000/test/apps/testing/ALOY-1000
Functional Test:
1. Run the test app on iOS
2. Check Resources/iphone/alloy/controllers/index.js:
3. For each property, the update function is generated once.66 doClick ? $.__views.genre.addEventListener("click", doClick) : __defers["$.__views.genre!click!doClick"] = true; 67 var __alloyId4 = function() { 68 $.title.text = _.isFunction(Alloy.Models.book.transform) ? Alloy.Models.book.transform()["title"] : Alloy.Models.book.get("title"); 69 $.author.text = _.isFunction(Alloy.Models.book.transform) ? Alloy.Models.book.transform()["author"] : Alloy.Models.book.get("author"); 70 $.genre.text = _.isFunction(Alloy.Models.book.transform) ? Alloy.Models.book.transform()["genre"] : Alloy.Models.book.get("genre"); 71 }; 72 Alloy.Models.book.on("fetch change destroy", __alloyId4);
- Tim Poulsen 2014-05-28 PR tested and merged
- Ewan Harris 2014-08-22
Verified fix on:
Mac OSX 10.9.4
Appcelerator Studio, build: 3.4.0.201408210941
Titanium SDK build: 3.4.0.v20140821144114
Titanium CLI, build: 3.4.0-dev
Alloy: 1.5.0-dev
iOS Simulator 7.1
Built the test to iOS and then checked Resources/iphone/alloy/controllers/index.js, the update function is generated once for each property.
Closing ticket.doClick ? $.__views.genre.addEventListener("click", doClick) : __defers["$.__views.genre!click!doClick"] = true; var __alloyId2 = function() { $.title.text = _.isFunction(Alloy.Models.book.transform) ? Alloy.Models.book.transform()["title"] : _.template("<%=book.title%>", { book: Alloy.Models.book.toJSON() }); $.author.text = _.isFunction(Alloy.Models.book.transform) ? Alloy.Models.book.transform()["author"] : _.template("<%=book.author%>", { book: Alloy.Models.book.toJSON() }); $.genre.text = _.isFunction(Alloy.Models.book.transform) ? Alloy.Models.book.transform()["genre"] : _.template("<%=book.genre%>", { book: Alloy.Models.book.toJSON() }); }; Alloy.Models.book.on("fetch change destroy", __alloyId2);