Skip to content

Commit cb5eb3c

Browse files
committed
Update readme
1 parent 601a0be commit cb5eb3c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,31 @@ present(alert, animated: true)
101101

102102
See [Alert.swift](https://github.com/AntonPoltoratskyi/NativeUI/blob/master/NativeUI/Sources/Alert/Alert.swift) for more details.
103103

104+
### Edge cases
105+
106+
When you need to present few alerts in a row you should set `shouldDismissAutomatically` flag to `false` and add action AFTER view controller initialization to be able to capture alert instance in action handler's closure.
107+
108+
```swift
109+
let cancelAction = Alert.Action(title: "Cancel", style: .primary)
110+
111+
let viewModel = Alert(
112+
title: "Your Title",
113+
message: "Your Message",
114+
actions: [cancelAction]
115+
)
116+
let alert = AlertViewController(viewModel: viewModel)
117+
alert.shouldDismissAutomatically = false
118+
119+
let confirmAction = Alert.Action(title: "Confirm", style: .default) { [weak alert] _ in
120+
alert?.dismiss(animated: true) {
121+
// present something else
122+
}
123+
}
124+
alert.addAction(confirmAction)
125+
126+
present(alert, animated: true)
127+
```
128+
104129
## Author
105130

106131
Anton Poltoratskyi

0 commit comments

Comments
 (0)