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

Additional helpers? #802

Closed
NullVoxPopuli opened this issue Mar 1, 2022 · 5 comments
Closed

Additional helpers? #802

NullVoxPopuli opened this issue Mar 1, 2022 · 5 comments

Comments

@NullVoxPopuli
Copy link
Contributor

kind of gauging interest here, kinda inspired by this thread: https://twitter.com/x8BitRain/status/1498563445058584576

and with the future of ESM / you only ship what you import (along with the recently merged first-class-component templates RFC),

I think we could add a lot more quality-of-life helpers that don't end up impacting the folks that don't use those helpers.

Like, we could add, maybe for strict-mode only:

  • noop

and not sure what else, because with the default helper manager RFC nearly implemented, we get a bunch more helpers for free, via:

let someArray = [[1], [2]]

<template>
  {{Array.prototype.flatten someArray}}
</template>

though, not ideal to do it this way.. cause Array.prototype.flatten is long

hmmmmmmm

thoughts? ideas?

@chriskrycho
Copy link
Contributor

chriskrycho commented Apr 19, 2022

@NullVoxPopuli I think for the examples you give here, having #756 plus a fix to make method dispatch work as expected would solve nicely. You can import noop (or define it) easily enough, and something like flat would "just work" as an instance on the array itself:

let someArray = [[1], [2]];

<template>
  {{(someArray.flat)}}
</template>

(In general, my own inclination is to have Ember focus on the things it specifically brings to the table, while letting lodash etc. handle general JS utility behavior.)

@wagenet
Copy link
Member

wagenet commented Jul 23, 2022

I’m closing since there doesn’t seem to be a path forward. However, I will happily reopen if one is proposed!

@wagenet wagenet closed this as completed Jul 23, 2022
@NullVoxPopuli
Copy link
Contributor Author

NullVoxPopuli commented Jul 23, 2022

Using @chriskrycho's suggestion,
atm, with methods on objects, we get an error: Uncaught (in promise) TypeError: can't convert undefined to object

Repro here

@chriskrycho
Copy link
Contributor

Yep, what we need is to see if we can fix method handling so it works the way people expect it to. Namely: if you actually have a reference to an object and call a method on it, that should work, just like in JS. The spec group has talked about this a few times and come up with some possibly workable ideas but we need someone with the relevant knowledge to champion and drive forward that work.

@chriskrycho
Copy link
Contributor

(To clarify, I don’t mean “someone from the community needs to volunteer,” though if someone does that’s awesome and we would try to help get them leveled up. But even on Framework the list of folks with expertise in the Glimmer syntax and semantics needed to drive this and time to work on it specifically is short at present.

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

No branches or pull requests

3 participants