Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are several things that are a bit complicated/confusing about
map
andmap!
:init
keyword also affects whetherf
runs (controlling the initialvalue is not orthogonal to execution, which spells trouble for
functions with side effects)
Base.map!
,map!(f, dest::Observable, args..)
does not eagerly update
dest
---that doesn't happen until one ofargs
updatesmap
always yields anObservable{Any}
, somewhat in contradictionto the behavior of
Base.map
(seemap
does not infere type #34)This redesigns
map
andmap!
to address these issues (fixes #34).It is a breaking change, although I've put in a depwarn for the case
where
init
was supplied. (The non-deprecated changes are so fundamentalthat this may not be useful, however.)
Now:
map
always runsf
on initial creationmap!
typically runsf
on the initial call, but it can besuppressed with an
update=false
keywordmap
creates anObservable{T}
with specificT
, but users cancontrol output
eltype
by usingmap!(f, Observable{S}(), args...)
instead.
Using the new API, the old
map
behavior can be obtained withor with an
init
it's