Skip to content

Commit 2177e13

Browse files
Update README to v1.4.0, and fixed small problems.
1 parent 1edbd2c commit 2177e13

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
# Tzeva Adom API
2-
Async Java API that listens to `Pikud Ha'oref API` and notifies registered listeners as soon as a Tzeva Adom happens.
2+
Async Java API that listens to `Pikud Ha'oref` and notifies registered listeners as soon as a Tzeva Adom happens.
33

44

55
## How to use
66
Let's create a notifier that logs a message when it's Tzeva Adom:
77
```java
88
TzevaAdomNotifier
9-
.requestFromPikudHaoref()
9+
.basedOnPikudHaoref()
1010
.every(Duration.ofSeconds(3)) //amount of delay between requests
1111
.onFailedRequest(exception -> LOGGER.error("Failed to request the last alert from Pikud Ha'oref", exception))
1212
.onTzevaAdom(alert -> LOGGER.info("Tzeva Adom at: " + alert.getCity()))
1313
.listen(); //async
1414
```
1515

16-
You can save the notifier object by calling `build()` instead of `listen()`, in order to add functionality or get data from it:
16+
You can save the notifier object by calling `build()` instead of `listen()` in order to add functionality or get data:
1717
```java
18-
TzevaAdomNotifier notifier = TzevaAdomNotifier
19-
// builder pattern goes here
18+
TzevaAdomNotifier notifier = new TzevaAdomNotifier.Builder()
19+
// the rest of the builder pattern
2020
.build();
21-
22-
notifier.listen();
21+
22+
// later
23+
Alert lastAlert = notifier.getLastAlert();
2324
```
2425

2526
Add more listeners anytime:
@@ -30,13 +31,12 @@ notifier.addListener(alert -> ...);
3031
Retrieve the Tzeva Adom alerts encountered while running:
3132
```java
3233
//run the notifier async and sleep for a day
33-
notifier.run();
34+
notifier.listen();
3435
TimeUnit.DAYS.sleep(1);
3536

3637
LOGGER.info("There were {} alerts in the last 24 hours:", notifier.getHistory().size());
3738

38-
//Pro Tip: TzevaAdomNotifier implements Iterable!
39-
for(Alert alert : notifier)
39+
for(Alert alert : notifier.getHistory())
4040
{
4141
LOGGER.info("Alert in {} at {}", alert.getCity(), alert.getDate());
4242
}
@@ -55,7 +55,7 @@ Maven Repository:
5555
<dependency>
5656
<groupId>com.github.DavidTheExplorer</groupId>
5757
<artifactId>Tzeva-Adom-API</artifactId>
58-
<version>1.1.0</version>
58+
<version>1.4.0</version>
5959
</dependency>
6060
```
6161

@@ -67,4 +67,3 @@ Either implement `AlertSource` or extend `JSONAlertSource` for JSON APIs, and th
6767
```java
6868
new TzevaAdomNotifier.Builder()
6969
.requestFrom(new YourAlertSource())
70-
.listen();

0 commit comments

Comments
 (0)