(&self, effect: F)
| 15 | } |
| 16 | |
| 17 | pub fn run<F>(&self, effect: F) |
| 18 | where |
| 19 | F: FnOnce() -> Option<Box<dyn FnMut()>>, |
| 20 | { |
| 21 | if let Some(mut cleanup) = self.cleanup.borrow_mut().take() { |
| 22 | cleanup(); |
| 23 | } |
| 24 | |
| 25 | if let Some(new_cleanup) = effect() { |
| 26 | *self.cleanup.borrow_mut() = Some(new_cleanup); |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | impl Default for UseEffect { |