Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add send_self method #365

Merged
merged 1 commit into from
Aug 20, 2018
Merged

Add send_self method #365

merged 1 commit into from
Aug 20, 2018

Conversation

therustmonk
Copy link
Member

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.

@davidkna
Copy link
Contributor

I'd prefer if this was kept without mut. I've been creating Callbacks with send_back in the view method to pass them down as props to avoid that the Model gets too cluttered.

@therustmonk
Copy link
Member Author

@davidkna Good point! I'll check it 👌

@therustmonk
Copy link
Member Author

... but I haven't seen this needs in my work. Could you explain, why do you need callbacks in properties? You should prefer to use agents to communicate components.

@davidkna
Copy link
Contributor

@deniskolodin I haven't used agents yet but I'll explore using them for this instead.
Being more familiar with react I've used callbacks to allow child components to notify their parents about changes related to props e.g. a child with an input informs the parent about a text change and has it update its state and rerender.

@therustmonk
Copy link
Member Author

therustmonk commented Aug 20, 2018

I have moved backward incompatible changes to a separate PR #367

@therustmonk
Copy link
Member Author

bors r+

bors bot added a commit that referenced this pull request Aug 20, 2018
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 <deniskolodin@gmail.com>
@bors
Copy link
Contributor

bors bot commented Aug 20, 2018

Build succeeded

@bors bors bot merged commit 8de5182 into master Aug 20, 2018
@madmaxio
Copy link

Wait, how is send_self different from calling the update?

@davidkna
Copy link
Contributor

@madmaxio I think calling update by itself can't cause a rerender.

@madmaxio
Copy link

Nice, thx.

bors bot added a commit that referenced this pull request Aug 27, 2018
367: Require mutable reference for send_back method call r=DenisKolodin a=DenisKolodin

This PR is separated from #365 to buy time to make backward incompatible changes.

Co-authored-by: Denis Kolodin <deniskolodin@gmail.com>
bors bot added a commit that referenced this pull request Aug 27, 2018
367: Require mutable reference for send_back method call r=DenisKolodin a=DenisKolodin

This PR is separated from #365 to buy time to make backward incompatible changes.

Co-authored-by: Denis Kolodin <deniskolodin@gmail.com>
@jstarry jstarry deleted the send-self branch August 10, 2019 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants