-
Notifications
You must be signed in to change notification settings - Fork 19
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
NamedTuple ERROR: Actor of type LoggerActor expects data to be of type #30
Comments
Thanks for your question! This is an unfortunate consequence of how Julia's type inference work. In Rocket.jl the operator julia> val = 1
1
julia> data = (value = val < 2 ? nothing : val, )
(value = nothing,)
julia> typeof(data) isa NamedTuple{(:value,), Tuple{Union{Nothing, Int64}}}
false This happens because Julia infers julia> NamedTuple{(:value,), Tuple{Nothing}} <: NamedTuple{(:value,), Tuple{Union{Nothing, Int64}}}
false This has nothing really to do with the Workaround 1Use the julia> result = source |> map(NamedTuple{(:value,), Tuple{Union{Nothing, Int64}}}, val -> @NamedTuple{value::Union{Nothing, Int64}}((val < 2 ? nothing : val, )))
julia> subscribe!(result, logger())
[LogActor] Data: NamedTuple{(:value,), Tuple{Union{Nothing, Int64}}}((nothing,))
[LogActor] Data: NamedTuple{(:value,), Tuple{Union{Nothing, Int64}}}((nothing,))
[LogActor] Data: NamedTuple{(:value,), Tuple{Union{Nothing, Int64}}}((2,))
[LogActor] Completed The Workaround 2Use julia> result = source |> map(Any, val -> (value = val < 2 ? nothing : val, ))
ProxyObservable(Any, MapProxy(Int64))
julia> subscribe!(result, logger())
[LogActor] Data: (value = nothing,)
[LogActor] Data: (value = nothing,)
[LogActor] Data: (value = 2,)
[LogActor] Completed |
Thanks, workaround 1 worked perfectly! |
MWE:
Errors with:
The text was updated successfully, but these errors were encountered: