Comments (11)
This is one of the top google results for Aurelia not reacting to array element changes. In my view, it's no big deal if Aurelia doesn't support this implicitly, but it'd be great to mention a precise recipe to work the issue around and force the update manually. For example, I have found the suggestion to replace this.samples_loaded[i] = true;
with this.samples_loaded.splice(i, 1, true);
but that doesn't help...
from binding.
@GBreeze aurelia does not observe array mutation via indexed assignment (eg arr[x] = y
) because it would require dirty-checking now that Object.observe is discontinued. Use splice
instead:
if (!Array.prototype.swap) {
Array.prototype.swap = function (newIndex: number, oldIndex: number) {
const temp = this[newIndex];
this.splice(newIndex, 1, this[oldIndex]);
this.splice(oldIndex, 1, temp);
return this;
}
}
from binding.
What about employing dirty checking in these scenarios? Is there any way to
communicate to the developer at runtime that he shouldn't expect it to
work?
On Apr 7, 2015 10:27 PM, "Rob Eisenberg" [email protected] wrote:
We can't fix this. It's impossible with native Array.observe. It's the one
flaw in the binding system. The only way to get around it is to create a
helper method on array that would notify the changes and use that instead
of the indexer when you want to change something. You can always use splice
as well. But, JS provides no way to override the indexer (at least no way
that isn't insane and non-scalable).—
Reply to this email directly or view it on GitHub
#64 (comment).
from binding.
Anyone having issues with this; check out this example: https://gist.run/?id=c3d618546a0fef10a266109465eed94c
by using splice and the property indexer (string) you can get the binding working - but I believe this is dirty checked.
from binding.
We can't fix this. It's impossible with native Array.observe. It's the one flaw in the binding system. The only way to get around it is to create a helper method on array that would notify the changes and use that instead of the indexer when you want to change something. You can always use splice as well. But, JS provides no way to override the indexer (at least no way that isn't insane and non-scalable).
from binding.
Basically, use dirty checking on array indexes...hmmm. That could work.
On Tue, Apr 7, 2015 at 11:18 PM, Matthew James Davis <
[email protected]> wrote:
What about employing dirty checking in these scenarios? Is there any way to
communicate to the developer at runtime that he shouldn't expect it to
work?
On Apr 7, 2015 10:27 PM, "Rob Eisenberg" [email protected] wrote:We can't fix this. It's impossible with native Array.observe. It's the
one
flaw in the binding system. The only way to get around it is to create a
helper method on array that would notify the changes and use that instead
of the indexer when you want to change something. You can always use
splice
as well. But, JS provides no way to override the indexer (at least no way
that isn't insane and non-scalable).—
Reply to this email directly or view it on GitHub
#64 (comment).—
Reply to this email directly or view it on GitHub
#64 (comment).
Rob Eisenberg,
President - Blue Spire
www.durandaljs.com
from binding.
Not sure if we should do anything about this or not just yet.
from binding.
Does #76 covers an expression like data[0].property
?
It seems my binding doesn't get notified when property
changes, even if it is defined as an ES property..
Forgot to mention that I have used Typescript inheritance in my view model, and that the data
array is defined on the base class and not on the viewmodel that is used by the view. It can be an issue?
from binding.
@jdanyow Since you are working on the binding docs currently, can you be sure to include this information and recommendation in that. (Along with any other common scenarios you've seen over the last months.)
from binding.
taking suggestions on how/when to warn about this issue: https://github.com/MeirionHughes/aurelia-template-lint/issues/82#issuecomment-250273617
from binding.
What is with polyfills, is there a workaround?
Example:
if (!Array.prototype.swap) {
Array.prototype.swap = function (newIndex: number, oldIndex: number) {
let temp = this[newIndex];
this[newIndex] = this[oldIndex];
this[oldIndex] = temp;
return this
}
}
this does not reflect on a 'repeat.for' binding :-|
from binding.
Related Issues (20)
- path expressions containing 'in' no longer working, 'in' treated as keyword HOT 3
- Issue with aurelia/binding typings HOT 12
- Issue with interpolation binding inside HTML `<option>` element HOT 2
- Checkbox event arguments in repeaters not binding correctly HOT 5
- @behel33 Thanks for creating the issue, I couldn't recreate the behavior you described, can you help fix this codesandbox https://codesandbox.io/s/x761qq5p3q HOT 1
- Infinite loop with 100+ observers HOT 17
- click.delegate bindings stop working HOT 14
- click.delegate firing for all clicks on firefox rather than just left click HOT 5
- Binding on role attribute not working in Firefox HOT 4
- Delegate event bubbling does not match native behavior in shadow dom
- Infinite loop in aurelia-bindingd.ts OverrideContext HOT 13
- parsing of template issue: ${moment().toISOString()} does not work HOT 1
- Parser Error: Invalid start of expression at column 0 in expression []
- Optimizing getter access HOT 1
- Matcher ignored within repeater HOT 7
- Delegate does not support shadow dom for Firefox
- getContextFor() doesn't handle a non-object bindingContext HOT 3
- Can we use/make attached/detached method inside aurelia custom element? HOT 3
- Binding checkboxes: custom matcher does not work when using repeat.for HOT 3
- SetterObserver keeps old value retained HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from binding.