Open kosich opened 3 years ago
I currently gravitate towards:
package name: rxjs-autorun
methods:
autorun
→ autorun
this name reflects well the usagerun
→ two aliases: c
and computed
similar to mobx & vue APIs$
→ two aliases: $
and track
_
→ two aliases: _
and probably read
(untracked
is the second nominate 🙂)E.g.:
c(() => $(a) + _(b))
c(() => {
return $(a) + _(b);
})
computed(() => track(a) + read(b))
computed(() => {
return track(a) + read(b);
})
Let me know what you think!
Do we need the short aliases?
cc @Jopie64
P.S: I think, we're in super alpha, so we don't need to bother about this too much and we can change the names later
Naming is often the hardest part 😫
I'm wondering, can you explain the user of the autorun
function? Maybe a use case?
For me it looks like it only cares about the side effects... Is that what it is about?
I'm not so sure about built in aliasses... A user can already do aliasses via the import syntax:
import { computed as c } from 'autorun';
And even with require something like
const { computed: c } = require('autorun');
If I remember correctly. Or do you have a different reason for using aliasses?
Furthermore, computed
sounds good to me. Hard to think of anything better. But that's more because I'm not good at naming things. 😬 For me it will probably become another (powerful) rx operator in the toolbox.
I like short names, especially when they are used a lot. So $
and _
are ok for me. Especially $
cause that's the convention extension for streams.
But I really would like it when those (also?) became arguments of the expression.
So those are my thoughts 😊
autorun
— yeah, side-effects mainly (I guess only side-effects)
Maybe also as easy-to-use connector to Observables for those not willing to dive into Rx API
I like the _
and $
for brevity so that we don't over-pollute expressions.
And added c
while writing that comment, it just felt as a natural counterpart — now I think c
is stupid :)
The benefits of having named short export:
The downsides were already described in the #1 :
_
and $
are both popular names _
can also be used as argument placeholderBut I really would like it when those (also?) became arguments of the expression.
Regarding this, I put that on hold on purpose while we figure out all that track/untrack weak/strong eager/late API.
I'm glad we agree on computed
! 🎉
While
$
,_
function names are short and are unobtrusive, I think we'll need more descriptive names. Also,run
function name doesn't reflect well what it does (as it doesn't immediately run the expression) and is not conventional.Maybe
autorun
needs renaming too.As suggested by @fkrasnowski
run
could be renamed to something likecomputed
orderived
orautopiped
$
and_
as indirectly indicated by @voliva could have additional export aliases, liketrack
(watch
,observe
, or …) andread
(silent
,muted
,sample
,untracked
, or …)Let me know what you think