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

Outlet reference protocol change for liquid-fire #14149

Merged
merged 1 commit into from
Sep 1, 2016

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Aug 29, 2016

This makes the outlet reference protocol compatible with normal NestedPropertyReferences.

The glimmer2-compatible version of liquid-fire uses dynamically-scoped variable accessors as implemented in glimmerjs/glimmer-vm#294 in order to read and write the outlet state. (This is the value that is named routeInfo in emberjs/rfcs#95, which exists to eventually make public API for it.)

That all works great except for one tiny annoyance in Ember itself: we can't bring an OutletReference into "userspace" and back again. Once we compute a value, we have an untyped POJO that results in a NestedPropertyReference when we pass it back into glimmer.

This change is the simplest thing that works. Alternatively, we should implement a real RouteInfo type (as described in emberjs/rfcs#95) so that the values can round-trip through userspace and still get converted back into typed references.

@homu
Copy link
Contributor

homu commented Sep 1, 2016

☔ The latest upstream changes (presumably #14177) made this pull request unmergeable. Please resolve the merge conflicts.

@rwjblue
Copy link
Member

rwjblue commented Sep 1, 2016

Due to working on #14177 I actually half way understand this. I think you need to update to incorporate the issues fixed in #14177 (that the outletName itself can be bound and that reference should affect the resulting tag). With these changes, it seems that the outlets key is also dynamic, so it should likely be part of the combined tag for the outlet component definition as well.

Can you add a test to https://github.com/emberjs/ember.js/blob/master/packages/ember-glimmer/tests/integration/outlet-test.js to help us ensure no regressions in this after landing?

@ef4
Copy link
Contributor Author

ef4 commented Sep 1, 2016

Yes, and this PR also needs updates to reflect glimmerjs/glimmer-vm#297. I will work on it.

This makes the outlet refrence protocol compatible with POJO references so they can round-trip through userspace without breaking (and adds a test to ensure they stay that way).

And it updates to glimmer 0.11.4:
 - the DynamicScope interface now include get/set.
 - we expose (as intimate API) `-with-dynamic-vars` and `-get-dynamic-var`
@ef4
Copy link
Contributor Author

ef4 commented Sep 1, 2016

Updated, tests green, new test added, and I have the liquid-fire test suite fully passing against this.
🎉

With these changes, it seems that the outlets key is also dynamic,

The outletState objects generated by the router in normal usage are never mutated. That is a deliberate design decision. Whenever something about the route changes, we generate a completely fresh new outletState object and send it downward. So I don't think the outlets key really needs to be tracked dynamically.

I see that some tests are mutating and reusing outletState objects as a shortcut. That is not really testing things the same way they work in apps. The tests in https://github.com/ember-animation/liquid-fire/blob/glimmer2/tests/integration/helpers/liquid-outlet-test.js deliberately copy the outletState each time they set it (look inside the asTop method) to avoid this issue while still keeping the tests from being annoying to write.

@rwjblue
Copy link
Member

rwjblue commented Sep 1, 2016

I see that some tests are mutating and reusing outletState objects as a shortcut. That is not really testing things the same way they work in apps.

Aha! I see. I will try to take a stab at refactoring in a future PR.

@rwjblue rwjblue merged commit 6c2b702 into emberjs:master Sep 1, 2016
@@ -290,6 +292,8 @@ export default class Environment extends GlimmerEnvironment {
return (vm, args) => SimpleHelperReference.create(helper.compute, args);
} else if (helper.isHelperFactory) {
return (vm, args) => ClassBasedHelperReference.create(helper, vm, args);
} else if (helper.glimmerNativeHelper) {
return helper.glimmerNativeHelper;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ef4 I think we can simplify this by making internal helpers just a function with this interface: https://github.com/tildeio/glimmer/blob/master/packages/glimmer-runtime/lib/environment.ts#L239-L241

Then you wouldn't need the isInternalHelper or glimmerNativeHelper flags – which are problematic because a userland helper can pretend to be one of those just by assigning that property on them.

Instead:

let builtInHelper = this.builtInHelpers[name];

if (builtInHelper) {
  return builtInHelper;
}

// do userland lookups...

wycats pushed a commit that referenced this pull request Sep 8, 2016
chancancode added a commit that referenced this pull request Sep 8, 2016
webark pushed a commit to webark/ember.js that referenced this pull request Oct 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants