Skip to content

Commit ece22fc

Browse files
authored
Update README.md
1 parent b306d8f commit ece22fc

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,47 @@
11
# NotificationCenter [![Build Status](https://travis-ci.org/Husseinhj/NotificationCenter.svg?branch=master)](https://travis-ci.org/Husseinhj/NotificationCenter) ![Nuget version](https://img.shields.io/nuget/v/NotificationCenter.svg?style=flat) ![downloads](https://img.shields.io/nuget/dt/NotificationCenter.svg?style=flat)
22
This library works like Objective-C and Swift NSNotificationCenter.
3+
4+
## Installation
5+
Use this command in Nuget Package Manager Console:
6+
7+
``` ruby
8+
PM> Install-Package NotificationCenter -Version 1.0.0
9+
```
10+
11+
## Methods
12+
### Subscribe
13+
To add an action with Key in NotificationCenter, You should use this code :
14+
15+
``` csharp
16+
NotificationCenter.Subscribe("KEY",Action);
17+
18+
private void Action()
19+
{
20+
Debug.WriteLine("Action was run");
21+
}
22+
23+
// or
24+
NotificationCenter.Subscribe("KEY",Action);
25+
26+
private void Action(object o)
27+
{
28+
Debug.WriteLine("Action was run with {0} object",o);
29+
}
30+
```
31+
32+
### Unsubscribe
33+
To remove your action in NotificationCenter, You should use this code :
34+
35+
``` csharp
36+
NotificationCenter.Unsubscribe("KEY");
37+
```
38+
39+
### Notify
40+
To invoke or notify all actions in unique Key, You should use this code :
41+
42+
``` csharp
43+
NotificationCenter.Notify(key: "KEY",data: 5);
44+
```
45+
46+
### KeepActionValue property
47+
Keep action data if key was not subscribed yet. It just work in Notify with data.

0 commit comments

Comments
 (0)