Differential / polymer-demo

Polymer & Meteor
164 stars 44 forks source link

Do not use Session as it's Migrated across reloads #13

Open RobertLowe opened 9 years ago

RobertLowe commented 9 years ago

Just ran into this.

https://github.com/Differential/polymer-demo/blob/master/client/init.coffee#L3

https://github.com/meteor/meteor/blob/devel/packages/session/session.js#L1 https://github.com/meteor/meteor/blob/devel/packages/reactive-dict/migration.js

ReactiveVars are not automatically migrated across hot code pushes, whereas Session state is.

http://docs.meteor.com/#/full/reactivevar

ryw commented 9 years ago

Hi Robert - what bad behavior did you observe as a result of this?

On Feb 12, 2015, at 4:28 AM, Robert Lowe notifications@github.com wrote:

Just ran into this.

https://github.com/Differential/polymer-demo/blob/master/client/init.coffee#L3

https://github.com/meteor/meteor/blob/devel/packages/session/session.js#L1 https://github.com/meteor/meteor/blob/devel/packages/reactive-dict/migration.js

ReactiveVars are not automatically migrated across hot code pushes, whereas Session state is.

http://docs.meteor.com/#/full/reactivevar

— Reply to this email directly or view it on GitHub.

schnie commented 9 years ago

Yea reactive var is probably a better way to do it. One of the issues that all this is attempting to fix could return. The goal of this little dance is to wait until polymer is ready before we even attempt to render our meteor templates via IR, which contain polymer elements. If polymer is not ready by the time they render, helpers and events on them could attempt to use polymer functionality on those elements before they have been upgraded. On a related note, we need to render IR to a child element due to an apparent incompatibility between some polymer interaction with the <body> tag and the way a default IR configuration uses blaze's event delegation. By default, Blaze delegates all events to the parent of the template the event map is defined on. IR overrides this behavior a bit by passing <body> as the parent element whenever it instantiates a new template instance, which delegates all events up to <body>. At some point, polymer seems to clobber this setup. By setting a child element as the root for IR we can avoid all that.

rgoomar commented 9 years ago

Reactive variables are being used now instead of Session which does make sense to me.

RobertLowe commented 9 years ago

Yea, that's what I did in the application I'm working on. ReactiveVar ftw