Created
March 2, 2017 12:58
-
-
Save dron247/4f94a36a3ac8310bc1cb40da439f63f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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