Skip to content

Commit a5b4e08

Browse files
authored
Update README.md
1 parent 5a71b4e commit a5b4e08

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ extension Firebaseable {
153153
return try fcm.sendMessage(container.make(Client.self), message: message).transform(to: ())
154154
}
155155
}
156+
157+
extension Array where Element == Firebaseable {
158+
func sendPush(title: String, message: String, on container: Container) throws -> Future<Void> {
159+
return try map { try $0.sendPush(title: title, message: message, on: container) }.flatten(on: container)
160+
}
161+
}
156162
```
157163
Optionally you can handle `sendMessage` error through defining `catchFlatMap` after it, e.g. for removing broken tokens or anything else
158164
```swift
@@ -170,7 +176,7 @@ Optionally you can handle `sendMessage` error through defining `catchFlatMap` af
170176
}
171177
```
172178

173-
e.g. I'm conforming my `Token` model to `Firebaseable`
179+
Then e.g. I'm conforming my `Token` model to `Firebaseable`
174180

175181
```swift
176182
final class Token: Content {
@@ -188,6 +194,6 @@ Token.query(on: req)
188194
.join(\User.id, to: \Token.userId)
189195
.filter(\User.email == "[email protected]")
190196
.all().map { tokens in
191-
try tokens.map { try $0.sendPush(title: "Test push", message: "Hello world!", on: req) }.flatten(on: req)
197+
try tokens.sendPush(title: "Test push", message: "Hello world!", on: req)
192198
}
193199
```

0 commit comments

Comments
 (0)