Skip to content

Instantly share code, notes, and snippets.

@dron247
Created March 2, 2017 12:58
Show Gist options
  • Save dron247/4f94a36a3ac8310bc1cb40da439f63f1 to your computer and use it in GitHub Desktop.
Save dron247/4f94a36a3ac8310bc1cb40da439f63f1 to your computer and use it in GitHub Desktop.
// multicallback example
namespace com.example {
class Runner {
var devices = new List<Item>();
void foo(){
devices.Add(new Item());
devices.Add(new Item(Handler));
}
void Handler(string data) {
// some handler stuff
}
}
class Item {
Action<string> listener;
public Item(Action<string> listener = null) {
this.listener = listener;
}
private void DoStuff() {
// ...some stuff...
if(listener != null) {
listener("some data");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment