-
-
Notifications
You must be signed in to change notification settings - Fork 629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CompositionTransaction and CompositionTransactionNotifier not work as per 367 #910
Comments
I don't think |
I am unable to replicate exactly in the gist im still looking into why. Can you explain why in #367 Im probably being dense sorry. |
Awaiting in the constructor should never worked. |
Ok so i have managed to replicate in the gist looks like it only occurs when I nest additional viewmodels. Up until that point as you say the bind => attached CompositionTransaction is observed. Whilst I would prefer to have all the steps between lifecycle state functional I really only need one to work so bind => attached is fine. Here is the gist. For me it outputs this:
If i modify the app.html to:
I get:
If i modify the app.html to
I get:
I'm probably doing something really dumb thanks for having a look. |
Any chance on an update on this? Its a bit of a blocker for me :( |
@bigopon Are you able to take a second look? |
@Spaceman1861 I think you are confused by the logs. They are behaving as documented for me. Note that the logs don't reflect the order of lifecycle correctly, as each widget has their own logs. Simple playable project for local experiment with some styling to highlight the issue with logs (extract zip and run a http-server in the folder) aurelia-comp-token.zip |
@bigopon I could be crazy but I think your gist is still showing incorrect behavior. Your gist outputs:
Note:
I would expect this to be:
Is this an incorrect assumption |
I see what you meant. I think you are correct. Let me check it again. |
The above is what I said, and it's horribly wrong, I didn't understand it enough. My apology. Here is an updated gist log showing the behavior you'd expect https://gist.run/?id=0de9543f3f53bf73cf891c4f7258a634 So the key point is to enlist composition transaction notifier before |
The timeout is just simulating a bunch of awaited ajax requests. Widget is attached => loads data related to the bind method => then bind fires. The reason im trying to do it this way is I want all the data loaded before proceeding to the bind step. I will review your gist as it appears to be functioning as I expect. It would appear that by removing the usage in the constructor we avoid calling done twice in the constructor and stop the cascaded offset of the notifier. |
I can confirm that if i only use the compositionTransactionNotifier to "Await" the bind step and nothing else it appears to work. |
@bigopon Ok so I attempted to translate only using bind into my app and I found that if the component is conditional its does not adhere to the transaction notifier. https://gist.run/?id=1beeeae39facd87ad9eec9c6e4c3d0db I have updated the gist with an example where some arbitrary trigger(in this case a timeout) causes the widget to be bound, it will ignore the transaction notifier. note: In my apps case this is not triggered by a timeout but when the state of the data changes a different widget is loaded. The state change is driven by websockets. |
For the updated gist:
For your scenario, I think you can easily employ an |
Would you be able to update the gist showing how you would implement it with the if / else i'm not following your suggestion at the moment. |
@Spaceman1861 I was giving that suggestion based on this:
I would normally hide <sub-widget if.bind='hasData'></sub-widget> And on data comes from ws or fetch, just turn The above is what I guessed out of what described. I think you may want to move this topic to Discourse (https://discourse.aurelia.io) or StackOverflow. It's better for future visibility. |
So you are suggesting i move the onus of the data loading to the parent widget? If this is the case, im not a huge fan of this solution. I would prefer to have the widget responsible for loading its own data. I have managed to create a work around tho. It just means i need to wrap the html in some dummy if binding within the widget.
As opposed to
I have done away with using the CompositionTransaction and put a bunch of wrapper functions around the attach / bind code. This is kinda just ignoring the Aurelia life cycle tho.
Thanks for all your input on this. |
@Spaceman1861 There is nothing preventing you from moving data loading to the child element. What I was suggesting was to |
I'm submitting a bug report
"aurelia-after-attached-plugin": "github:aurelia-ui-toolkits/aurelia-after-attached-plugin@^0.1.3",
"aurelia-bootstrapper": "npm:aurelia-bootstrapper@^2.3.0",
"aurelia-cookie": "npm:aurelia-cookie@^1.0.10",
"aurelia-event-aggregator": "npm:aurelia-event-aggregator@^1.0.1",
"aurelia-fetch-client": "npm:aurelia-fetch-client@^1.6.0",
"aurelia-framework": "npm:aurelia-framework@^1.3.0",
"aurelia-kendoui-bridge": "npm:aurelia-kendoui-bridge@^1.8.0",
"aurelia-pal": "npm:aurelia-pal@^1.8.0",
"aurelia-pal-browser": "npm:aurelia-pal-browser@^1.8.0",
"aurelia-router": "npm:aurelia-router@^1.6.3",
"aurelia-templating-resources": "npm:aurelia-templating-resources@^1.7.1"
Please tell us about your environment:
Operating System:
Windows 10
Node Version:
8.11.1
NPM Version:
6.4.0
Aurelia CLI OR JSPM OR Webpack AND Version
JSPM 0.16.53
Browser:
all
Language:
TypeScript 3
Current behavior:
Im am trying to setup usage of CompositionTransaction as described in #367.
This outputs
14:27:36.102 CvLogger.ts:3 Constructor called (3) [Dashboard, 1]
14:27:36.162 CvLogger.ts:3 Bind called (3) [Dashboard, 2]
14:27:36.258 CvLogger.ts:3 Attached called (3) [Dashboard, 3]
14:27:41.109 CvLogger.ts:3 Constructor done (3) [Dashboard, 2]
14:27:41.167 CvLogger.ts:3 Bind done (3) [Dashboard, 1]
14:27:41.263 CvLogger.ts:3 Attached done (3) [Dashboard, 0]
Expected/desired behavior:
I expect for each lifecycle step to finished 5 seconds after the last eg
14:27:00.000CvLogger.ts:3 Constructor called (3) [Dashboard, 1]
14:32:00.000CvLogger.ts:3 Constructor done (3) [Dashboard, 0]
14:32:00.000CvLogger.ts:3 Bind called (3) [Dashboard, 1]
14:37:00.000CvLogger.ts:3 Bind done (3) [Dashboard, 0]
14:37:00.000CvLogger.ts:3 Attached called (3) [Dashboard, 1]
14:42:00.000CvLogger.ts:3 Attached done (3) [Dashboard, 0,]
I wish have data loaded before moving to the next step.
The text was updated successfully, but these errors were encountered: