Skip to content
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

Refactor the signal connection syntax #8

Closed
idanarye opened this issue Feb 5, 2021 · 1 comment
Closed

Refactor the signal connection syntax #8

idanarye opened this issue Feb 5, 2021 · 1 comment

Comments

@idanarye
Copy link
Owner

idanarye commented Feb 5, 2021

With #4, my solution to #2 of adding a signals_inhibit method that fills an optional closure (79abc12) is no longer going to work, because the same builder utilizer can be used to generate multiple signal types for multiple actors - so we can no longer just have a single optional field with that closure. While this can be a new variation of connect_signals, we also have connect_signals_tagged so we'll need 4 variants, and as we add new features this is going to either grow exponentially or add many many arguments to that method. I like neither way - we need a better solution.

c.c. @piegamesde

@idanarye
Copy link
Owner Author

idanarye commented Feb 5, 2021

I would like to use a fluent interface, so maybe something like this:

ctx.signals::<MySignal>().tagged(my_tag).inhibit(|signal| match { ... }).connect();

Both tagged and inhibit are optional, of course.

Alternatively, I can use something like this:

ctx.connect_signals(MySignal::connector().tagged(...).inhibit(...));

The benefit here is that the connector object is the same, so if we want to support the fluent interface for building the actor - we can:

builder
    .actor() // might need to add ::<MyActor> here, but that's another story
    .connet_signals(MySignal::connector().tagged(...).inhibit(...))
    .make(MyActor {
        widgets: builder.widgets()
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant