Skip to content

Commit 98b0071

Browse files
committed
update readme: example section
1 parent 29040dd commit 98b0071

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

+22
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,25 @@ implementation group: 'io.github.maroodb', name: 'simple-event', version: '1.0.1
3333
...
3434
}
3535
```
36+
37+
## Example
38+
39+
```
40+
41+
var simpleEvent = new SimpleEvent<String>();
42+
43+
var observable = simpleEvent.subscribe("MyTopic", (message) -> {
44+
// do something with your message, or just print it!
45+
System.out.print(message);
46+
});
47+
48+
simpleEvent.publish("MyTopic", "Hello World!");
49+
50+
// Unsubscribe from topic
51+
observable.unsubscribe();
52+
53+
// nothing will happen
54+
simpleEvent.publish("MyTopic", "Hello World!");
55+
56+
57+
```

0 commit comments

Comments
 (0)