jakmeier / nuts

Nuts is a Rust library that offers a simple publish-subscribe API, featuring decoupled creation of the publisher and the subscriber.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Subscribe without activity

jakmeier opened this issue · comments

Idea:

Allow subscriptions without an activity.

Current Status

With the current API, a subscription can only be created on an activity. This sometimes forces programmers to create a dummy activity to react on a specific message.

Example:

  let dummy = nuts::new_activity(());
  dummy.subscribe(|_: &mut(), msg: &Message| { /*...*/ });

Possible new syntax

  nuts::subscribe(|msg: &Message| { /*...*/ });

Also feasible to add:

  nuts::subscribe_domained(&MyDomain::DomainA, |domain, msg: &Message| { /*...*/ });