ember-resources icon indicating copy to clipboard operation
ember-resources copied to clipboard

re-callable `trackedFunction`

Open velrest opened this issue 3 years ago • 7 comments

velrest avatar Jul 12 '22 09:07 velrest

I haven't tested this fully with tracking context yet but its a work in progress and i figured i'd open a draft pr.

velrest avatar Jul 12 '22 09:07 velrest

I know it's not necessarily nice to put values on a function object, but i think the ergonomics of this approach are quite nice. I also played around a bit with putting a "re-execute" function onto the State but i had some problems with context and reassigning the values.

velrest avatar Jul 12 '22 09:07 velrest

had some problems with context and reassigning the values.

I think we'll still want to explore putting things on the State class -- what problems were you running in to?

NullVoxPopuli avatar Jul 12 '22 09:07 NullVoxPopuli

had some problems with context and reassigning the values.

I think we'll still want to explore putting things on the State class -- what problems were you running in to?

Out of curiosity, is it because of the API or maybe because the implementation is a bit messy?

velrest avatar Jul 12 '22 10:07 velrest

Out of curiosity, is it because of the API or maybe because the implementation is a bit messy?

classes have way better type inference than the dynamic approach presently implemented in this PR. ember-resources is aiming for maximum Glint support with maximum type inference ability (yay!) :partying_face:

NullVoxPopuli avatar Jul 12 '22 11:07 NullVoxPopuli

I see, that`s a very good argument :smile: .

I'm not really a typescript user and am more used to a more "functional" programming style so that's why i tried to implement it a bit more declarative and in a dynamic way.

I'll have a look again and put this into the State.

velrest avatar Jul 12 '22 11:07 velrest

@NullVoxPopuli I implemented the function on the class as you proposed an the test is now green, feel free to have a look at this again :smile:

velrest avatar Sep 29 '22 16:09 velrest

I gave a shot at this here: https://github.com/NullVoxPopuli/ember-resources/pull/665

thoughts?

NullVoxPopuli avatar Oct 27 '22 03:10 NullVoxPopuli

Gonna close in favor of: https://github.com/NullVoxPopuli/ember-resources/pull/665

@velrest , thanks a ton for pushing this forward!

NullVoxPopuli avatar Oct 28 '22 16:10 NullVoxPopuli