Question about naming and interfaces
See original GitHub issueI was just curious what was the reasoning behind .value
from fromPromise
and current()
from fromResources
and lazyObservable
as those names don’t appear anywhere else in mobx
.
In RxJs most of the return values are Rx.Observable
. Coming from there, one would expect these to implement some common interface like boxed values (.get
). What’s the equivalent predictable interface for the return values inmobx
and mobx-utils
?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Naming an interface that does something and its opposite
Maybe I'm overthinking about naming, but it's a problem I've encountered several times and it was really annoying every time.
Read more >Interface naming in Java [closed] - Stack Overflow
Using interfaces in clients is the standard best way to program, so interfaces names should be as short and pleasant as possible.
Read more >Answers to Questions and Exercises: (The Java™ Tutorials ...
Question : What interface represents a double-ended queue? Answer: Deque; Question: Name three different ways to iterate over the elements of a List...
Read more >Solved Which statement is correct? Select one: a. Interfaces
Question: Which statement is correct? Select one: a. Interfaces are another name for classes. O b. To write an interface, all the methods...
Read more >Network interfaces names question | Proxmox Support Forum
Hi, I've created following network setup: iface eno1 inet manual iface eno1.191 inet manual auto vmbr191 iface vmbr191 inet static address.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Btw check the current description for
initialValue
offromResource
in the README.md 😃Observability in MobX is not defined by interface. Any object can be observable (consumed by Mobx) no matter what the interface is. Unlike RxJS there aren’t methods which consumes a special “observable” interface. Why would you introduce an abstraction, if it’s not used or required by anything? The values produced by
Rx.Observable
(the value supplied to observer’snext
) also have an arbitrary interface, these are the actual interfaces you have to work with, but these can’t be observed, therefore must be wrapped intoRx.Observable
, which is not the MobX case. Yes you can create a function, which accepts anyRx.Observable
… imagine that there wouldn’t be any function in RxJS requiring this interface and only thing you could do withRx.Observable
is to obtain (get) some arbitrary value it produces. How is it useful? You have a generic type without any generic methods…Because the ObservablePromise is not just an observable result of promise, the RxJS analogy would not look like this:
but rather like this:
The MobX analogy of the former would actually be:
And observable promise with a common interface inspired by
Rx.Observable
would imho looked like this:The returned objects does not neccesarily represents the same thing as suggested in above code samples, therefore they don’t have to share the same interface. Again object returned from
fromPromise
does not represent the data “sourced” fromPromise
, it represents the Promise itself (but consumable by MobX). However most of these returned objects have in common that they “wrap” some “value” (this is quite vague definition however - shouldclass UserList
have.get()
to return the actual array of users? probably not right?). So we could came up with a consensus that these “value holders” can always expose the “most significant value” with.get()
which is aligned with boxed observables. But we will end up with an interface:how consistent is that? So maybe:
This seems reasonable to me, but it’s not aligned with
boxed
, so we would have to change them:That seems nice from the perspective of “API seems familiar”, but is it useful as an abstraction? Do these “values” really represent the same thing? Is it neccesary?
They convert specific non-observable interface to an observable object, whose interface tries to reflect/describe the original non-observable thing (which may be a single value or something more complex).
I can imagine that it could suggest (maybe even distinguish) that the value changes spontaneously over time, unlike the boxed which must be explicitely set. But
get()
seem equally fine to me in this case.Currently not, but technically could be, or
initial()
perhaps … I am just speculating what could be the author’s thoughts at the time of writing…Btw I don’t mind aligning the naming, I just feel the motivation/reasoning could be a bit off (especially in relation to RxJS).