Skip to content
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

Fire two events when logging in #536

Open
martijnjanssen opened this issue Nov 16, 2017 · 4 comments
Open

Fire two events when logging in #536

martijnjanssen opened this issue Nov 16, 2017 · 4 comments

Comments

@martijnjanssen
Copy link
Contributor

This applies for the lancie-login-form but I'm placing it here since majority of the changes should be made and all behaviour should be checked in this repository.

Currently we use one event to notify that the user is logged in, while this is correct, we can improve in predictability. I had to add an async call recently to wait for all the user's properties to propogate down in to the dom, which is pretty wierd and unwanted.

I propose a change renaming the logged-in event to login-data containing the current data in the event. Immediately after, we should fire a new logged-in event. This ensures that all properties have propogated down the dom (since the eventhandlers trigger immediately on an event) before taking any acions that depend on the user being completely logged-in.

What do you think about this @TimvdLippe?

@TimvdLippe
Copy link
Member

Hm, I am not sure if I follow regarding the original issue. Polymer flushes property effects after each cycle, but should update all property values immediately. Nonetheless, 2 events is a better solution than a random async 👍

@martijnjanssen
Copy link
Contributor Author

The issue was that we listen to the logged-in event to save the user data. The problem with this is that we wanted to take action on the fact that the user was logged in, but since the eventlistener for this is closer to the origin of the event, the code reacting to this event was executed before the user data had bubbled up and propogated down. The user was not fully logged in yet due to the fact how events work.

@TimvdLippe
Copy link
Member

TimvdLippe commented Nov 17, 2017 via email

@martijnjanssen
Copy link
Contributor Author

martijnjanssen commented Feb 15, 2018

We can fix this by changing the event we fire from the lancie-form from a response event to a form event. This allows us to catch with on-form, instead of on-response which is an event fired twice (once from the iron-form and one from the lancie-form).

This should be done for all lancie-form usages, meaning that the lancie-login-form also has to be changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants