-
Notifications
You must be signed in to change notification settings - Fork 0
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
action()
Factory
#28
action()
Factory
#28
Conversation
// Invocation Styles: | ||
// | ||
// 1. (action) | ||
// | ||
// - `<button {{on "click" (incOne)}}>Inc</button>` | ||
// - `<button {{on "click" (inc 10)}}>Inc</button>` | ||
// - `<Step @inc={{10}} @push={{(inc)}}>Inc</Step>` | ||
// | ||
// 2. (fn (action)) | ||
// | ||
// - `<button {{on "click" (fn (incOne))}}>Inc</button>` | ||
// - `<button {{on "click" (fn (inc 10))}}>Inc</button>` | ||
// - `<button {{on "click" (fn (inc) 10)}}>Inc</button>` | ||
// - `<Step @inc={{10}} @push={{(fn (inc))}}>Inc</Step>` | ||
// | ||
// 3. (command action) | ||
// | ||
// - `<button {{on "click" (command incOne)}}>Inc</button>` | ||
// - `<button {{on "click" (command (inc 10))}}>Inc</button>` | ||
// - `<Step @inc={{10}} @push={{command inc}}>Inc</Step>` |
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.
These are some API Design ideas. Please give your feedback.
They are declarative so far, but I think, they can be turned imperative, too - somewhat around these lines:
// ---
const add = action(({ services }) =>
(a: number, b: number) => services.adder.add(a, b)
);
const doAdd = add(owner);
doAdd(3, 5);
const addOne = (b: number) => doAdd(1, b);
addOne(5);
so basically, action()
returns a factory, than the final function itself - is there a known way around this? 😇
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.
how else would you get the owner in there? it's gotta be wired in from either the user, or the manager infra
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.
In my defense: The imperative API wasn't there from the start at all. I only focused on the declarative API as its main citizen, but realized, this can be done, too.
I'm less concerned about connecting it with the owner (that's as you said provided or manager infra).
What I'm most interested in (under the terms of what's possible given ember's API):
Does it "feel" good to be used or is it "clumsy"/stiff, rather than inviting to be used? (for both imperative and declarative API)
Testing some APIs