Skip to content

Unable to build signals from costructors #12

Description

@rcalxrc08

Hi, very nice library; I have noticed the following:
Assume you have a type where you have specified the constructor:

struct Trial
       x::Float64
       Trial(x_::Float64)=new(x_)
end

If I try to build a Signal from that I get:

Signal(Trial,1.0)
ERROR: MethodError: no method matching Signal(::Type{Trial}, ::Float64)
Closest candidates are:
  Signal(::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at .julia\packages\Signals\559HJ\src\Signal.jl:11
  Signal(::Function, ::Any...; state, strict_push, pull_type, v0) at .julia\packages\Signals\559HJ\src\Signal.jl:52
  Signal(::Any; kwargs...) at .julia\packages\Signals\559HJ\src\Signal.jl:47
Stacktrace:
 [1] top-level scope at REPL[31]:1

The trivial workaround is to build the signal directly using:

sig=Signal(Trial(1.0))
Signal
value: Trial(1.0)

But this would not work in case 1.0 is a signal.
The proper way to do this is to build the Signal using the do syntax, but in case of multiple structs in can be awful to read.
Would it be possible to implement a signal costructor for types as well?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions