-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[FEATURE] if helper inline form #9718
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
Conversation
|
Feature flag is absolutely needed! :-) |
a4c33ef to
ee7bed3
Compare
|
I discussed a bit with Kris and we decided to want a slightly different implementation of the ConditionalStream. Basically, we should store |
|
Here's what I had in mind (I changed the variable names to match the spider monkey API): import Stream from "ember-metal/streams/stream";
import { read } from "ember-metal/streams/read";
import { create as o_create } from "ember-metal/platform";
function ConditionalStream(test, consequent, alternate) {
this._super(conditionalValueFn);
this.oldTest = undefined;
this.test = test;
this.consequent = consequent;
this.alternate = alternate;
}
ConditionalStream.prototype = o_create(Stream.prototype);
ConditionalStream.prototype._super = Stream;
function conditionalValueFn() {
var test = !!read(this.test);
if (test !== this.oldTest) {
if (this.oldTest === true) {
this.consequent.unsubscribe(this.notify, this);
}
if (this.oldTest === false) {
this.alternate.unsubscribe(this.notify, this);
}
if (test === true) {
this.consequent.subscribe(this.notify, this);
}
if (test === false) {
this.alternate.subscribe(this.notify, this);
}
this.oldTest = test;
}
return test ? read(this.consequent) : read(this.alternate);
}
export default ConditionalStream; |
ee7bed3 to
3d8e308
Compare
|
Hi @mmun, I updated the code based on your example |
3d8e308 to
c58451d
Compare
|
Thanks. I'm going to do a little touch up later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return value is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean? the return here is essential.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this is a sub expression, not the if helper.
And return values now append a simple view: https://github.com/emberjs/ember.js/blob/master/packages/ember-htmlbars/lib/hooks/content.js#L13
New to me!
c58451d to
31bd85c
Compare
Adds a basic version of if helper in inline form. In the moment ids aren't support.Bindings are supported, @mmun helped me to add it.
I added this behind a feature flag, not sure if it's needed, though.