I have a parent with an object data and I sent to the child part of it. I hope that when the parent is updated the child should be updated to.
groupProps is an object that every property has a lines array. In example: groupProps[1].lines[3] can exist.
<nova-grup v-for="group in m.groups"
:group="group"
:groupProp="groupProps[group.id]"
>
</nova-grup>
The first time it's working fine. The problem is when groupProps is changed the child isn't. For example, when changing or adding a line to groupProps.lines.
I have also noted that any computed variable based on the object isn't updating neither. Is this a limitation of vuejs? I'm using some lodash functions inside the computed variable
OK, it is a limitation.
https://v2.vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats
Finally I solved it doing this.myvar = Object.assign({}, this.myvar );
Related
I am creating 2 elements dynamically in QML and need to assign them each an anchor binding. When I add the anchors.right and anchors.left syntax to the properties object of the createObject() function, the anchors are not working:
current_column_on_left = column_component.createObject(parent_element, {anchors.right: previous_column_on_left.left})
current_column_on_right = column_component.createObject(parent_element, {anchors.left: previous_column_on_left.right})
Qt Creator gives me the annotation/error "Expected token ','". I also tried making them strings and camel case, neither of which worked. However, when I add the property bindings separately using Qt.binding() function, everything works fine:
current_column_on_left.anchors.right = Qt.binding(function(){return previous_column_on_left.left})
current_column_on_right.anchors.left = Qt.binding(function(){return previous_column_on_right.right})
Why is the first code block not working? I would prefer not to have the two extra lines of code if I can avoid it.
The error is because javascript doesn't know what property groups are - only qml does.
This is also invalid logic. In createObject(parent_element, {anchors.left: previous_column_on_left.right}) property previous_column_on_left.right is resolved when qreating the javascript {}-style object, which leaves you bound to a fixed anchor which is never changed. But Qt.binding has a function, and resolves nothing when creating the object, which provides you with the correct binding.
I need to make sure that children added to a DatabaseReference are processed in order. It is possible that the branch where the children are being added, gets multiple children added to it once. When the children are added at small intervals, everything works fine.
To tackle this, I've already implemented an index based solution. I add a field "index" in each child and ensure on Cloud Functions (the code that adds these children) that this index is incremental for all children. I then do the following to implement it:
MyDatabaseReference.OrderByChild("index").ChildAdded += HandleTheChild;
Most of the time this works, but there are still times when I get bugs similar to when I faced bugs due to wrong ordering of the children. My hypothesis is that the HandleTheChild function is triggered in order always, but it is possible that a child starts to be handled before the previous child is completely processed by the HandleTheChild function. This is creating some race conditions in their parallel execution. I want that each child be processed only after all previous children have been processed in the order they are arriving. Is my hypothesis wrong? If not, should I go forward with an implementation of the solution of the Producer-consumer problem on my Unity client?
When you first attach a listener to ChildAdded it fires for all children, in the order that you request them.
After that, the ChildAdded listener fires when a child is added to the database. In this case, the child may be inserted somewhere in the middle of the data (e.g. if its index is lower than existing indexes. The ChildAdded listener will fire and has a PreviousChildName property for this case. This contains the key/id/name of the number after which the new child was added.
My guess is that you're not using PreviousChildName, but (as Doug commented) it's hard to be certain without seeing that code.
There is a parent element. One of its property is an array of objects. This array is initialised in the ready function. The display of this array is handed down to a child element. What I want to do is to update the quantity of each element in the array whenever the multiplier property changed. I tried to use the override dirty checking technique described in the docs but couldn't get it to work. I would appreciate some guidance.
[plunker link][1]
[1]: http://plnkr.co/edit/pCZyUC7YtgUU8cpejNpj?p=info
Here is working example: Plunk
Few things are corrected, one is this:
//DO not use 'this.setItems.0.quantity.value', but:
this.set('setItems.0.quantity.value', newQuantity);
console.log("New arr val: ");
console.log(this.setItems[0].quantity.value);
Docs:
https://www.polymer-project.org/1.0/docs/devguide/model-data
https://www.polymer-project.org/1.0/docs/devguide/data-binding#array-binding
I have a flex4 applciation (mx+spark). When I use:
FlexGlobals.topLevelApplication.styleManager.loadStyleDeclarations(skinName, true);
This works fine: new style is applied.
The trouble is when I apply a new style, it mixes both: this happens because I need to Unload style first.
I try to unload it with:
FlexGlobals.topLevelApplication.styleManager.unloadStyleDeclarations("style/normal.swf",false);
And I always got an error:
ReferenceError: Error #1069: La property 0 cannot be found on Number
and there is no default value.
at normal/unloadOverrides()[null/normal-generated.as:721]
at normal/unload()[null/normal-generated.as:676]
Any idea on how to load/unload swf css in Flex4?
The styles will be updated the next time one of the following methods is called with the update property set to true:
clearStyleDeclaration()
loadStyleDeclarations()
setStyleDeclaration()
unloadStyleDeclarations()
Typically, if you call the one of these methods multiple times, you set this property to true only on the last call, so that Flex does not call the styleChanged() method multiple times.
More information here.
I'm having some issues when calling getItemIndex on an ArrayCollection with a filterFunction set.
I do something like myAC.removeItemAt(myAC.getItemIndex(myObject)), which works fine when the filtering hasn't been applied. As soon as filtering is applied, getItemIndex seems to return -1 in every case.
Has anyone come across this before? What the best way to remove an item form a filtered ArrayCollection?
Thanks a lot.
Evan
What exactly is your filter filtering out? If you've filtered out everything, getItemIndex should return -1.
Are you hoping to remove items that are still visible when your filter has been applied? If you still want to remove an item that's filtered out, you could temporarily disable the filter:
var filter:Function = ac.filterFunction;
ac.fiterFunction = null;
ac.refresh();
// remove item
ac.filterFunction = filter;
ac.refresh();
I think you'll find there is a source object within the ArrayCollection. What you are seeing is a view of the underlying data with a sort or filter applied. You really want to delete from the underlying source object.
Any time I've dealt with adding and removing items from ArrayCollections in Flex, I've always kept a copy of the original ArrayCollection. Any adding or removing of items happen to that original copy.
Once the changes have been made to the original, I move those forward to the filtered list.
Remove it from source directly
arrayCollection.source.splice(i, 1)
Yeah, so I did find out that I was changing the property of the object - to one that would have it filtered out - prior to trying to remove it. Of course I would get -1 in that case. My mistake.
Ended up going with your suggestion, Stiggler. Seems to work fine, though it seems like there should be a less hackish way to handle this type of thing. Perhaps a parameter you could pass to removeItemAt that would let you access the unfiltered collection.
Anyway, thanks to both of you for your responses. Much appreciated.