Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
captain-yossarian committed Mar 7, 2020
1 parent 2b90c38 commit d4dd3f6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/html/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ cfg_if! {
/// Updates for a `Component` instance. Used by scope sender.
pub(crate) enum ComponentUpdate<COMP: Component> {
/// Wraps messages for a component.
Message(COMP::Message),
Message(Into<COMP::Message>),
/// Wraps batch of messages for a component.
MessageBatch(Vec<COMP::Message>),
MessageBatch(Vec<Into<COMP::Message>>),
/// Wraps properties for a component.
Properties(COMP::Properties),
}
Expand Down Expand Up @@ -108,20 +108,20 @@ impl<COMP: Component> Scope<COMP> {
}

/// Send a message to the component
pub fn send_message(&self, msg: COMP::Message) {
pub fn send_message(&self, msg: Into<COMP::Message>) {
self.update(ComponentUpdate::Message(msg));
}

/// Send a batch of messages to the component
pub fn send_message_batch(&self, messages: Vec<COMP::Message>) {
pub fn send_message_batch(&self, messages:Vec<Into<COMP::Message>>) {
self.update(ComponentUpdate::MessageBatch(messages));
}

/// This method creates a `Callback` which will send a message to the linked component's
/// update method when invoked.
pub fn callback<F, IN>(&self, function: F) -> Callback<IN>
where
F: Fn(IN) -> COMP::Message + 'static,
F: Fn(IN) -> Into<COMP::Message> + 'static,
{
let scope = self.clone();
let closure = move |input| {
Expand All @@ -135,7 +135,7 @@ impl<COMP: Component> Scope<COMP> {
/// component's update method when called.
pub fn batch_callback<F, IN>(&self, function: F) -> Callback<IN>
where
F: Fn(IN) -> Vec<COMP::Message> + 'static,
F: Fn(IN) -> Vec<Into<COMP::Message>> + 'static,
{
let scope = self.clone();
let closure = move |input| {
Expand Down

0 comments on commit d4dd3f6

Please sign in to comment.