Skip to content

Commit

Permalink
Merge yewstack#365
Browse files Browse the repository at this point in the history
365: Add send_self method r=DenisKolodin a=DenisKolodin

In practice, often required a method to send messages itself to a component immediately.
This PR adds: `send_self` method and add a requirement for a mutable reference to `send_back` method.

Co-authored-by: Denis Kolodin <[email protected]>
  • Loading branch information
bors[bot] and therustmonk committed Aug 20, 2018
2 parents 49319b8 + 8de5182 commit 7e921ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

- Added `SubmitEvent` with `onsubmit` rule.

- Added `send_self` method to `ComponentLink` to send messages itself immediately.

[Web Workers API]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API

### Bug fixes
Expand Down
5 changes: 5 additions & 0 deletions src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ where
};
closure.into()
}

/// This method sends a message to this component immediately.
pub fn send_self(&mut self, msg: COMP::Message) {
self.scope.send_message(msg);
}
}

/// A context which contains a bridge to send a messages to a loop.
Expand Down

0 comments on commit 7e921ff

Please sign in to comment.