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

Avoid code reuse in agents #1

Merged
merged 1 commit into from
Sep 24, 2019

Conversation

jstarry
Copy link

@jstarry jstarry commented Sep 23, 2019

Hey @hgzimmerman I decided to see what it would take to get rid of some duplicated code, let me know what you think

@@ -92,7 +92,7 @@ pub trait Dispatched: Agent + Sized + 'static {
/// bridge around if you wish to use a dispatcher. If you are using agents in a write-only manner,
/// then it is suggested that you create a bridge that handles no-op responses as high up in the
/// component hierarchy as possible - oftentimes the root component for simplicity's sake.
fn dispatcher() -> Box<dyn Dispatcher<Self>>;
fn dispatcher() -> Box<dyn Bridge<Self>>;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favor of creating a distinct types for Bridges and Dispatchers. I feel like the distinct types communicate that the object they got from dispatcher behaves differently than one returned from bridge.

Maybe newtyping like DispatcherHandle(Box<dyn Bridge>) to indicate that it is distinct might be worth doing? That would make the API look funky with one bridgelike function returning a trait object, and the other a newtype of a trait object. Some breaking change might be needed down the line to make those behave similarly (with something like BridgeHandle(Box<dyn Bridge>).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to merge this, and add the newtype around the response for bridge. Thanks for simplifying the implementation.

@hgzimmerman hgzimmerman merged commit 87fa037 into hgzimmerman:dispatch_bridge Sep 24, 2019
hgzimmerman pushed a commit that referenced this pull request Sep 27, 2019
hgzimmerman pushed a commit that referenced this pull request Sep 27, 2019
* Early msgs queue for Public worker

* Early msgs queue for Public worker

* update (#1)

* Fix typo

* Require fmt in travis script

* Apply cargo format to all modules

* ??

* Merge (yewstack#2)

* Fix typo

* Require fmt in travis script

* Apply cargo format to all modules

* avoid allocating in diff_classes

* avoid allocating for diff_kind

* avoid allocating for diff_value

* simplify diff_attributes and avoid allocations

* return iterator for diff_classes and diff_attributes

* rustfmt on vtags

* clean apply_diff

* more cleaning

* apply suggestions

* Update proc-macro2, syn and quote to 1.0

CLOSES yewstack#590

* Fixed typo

* Add support for optional callbacks to component properties

* Add tests for a component with optional callback

* Fix typo

* Add `Classes` to prelude

* binary ser/de issue fix

* merge (yewstack#3)

* Fix typo

* Require fmt in travis script

* Apply cargo format to all modules

* avoid allocating in diff_classes

* avoid allocating for diff_kind

* avoid allocating for diff_value

* simplify diff_attributes and avoid allocations

* return iterator for diff_classes and diff_attributes

* rustfmt on vtags

* clean apply_diff

* more cleaning

* apply suggestions

* Update proc-macro2, syn and quote to 1.0

CLOSES yewstack#590

* Fixed typo

* Add support for optional callbacks to component properties

* Add tests for a component with optional callback

* Fix typo

* Add `Classes` to prelude

* added bincode type for data ser de

* fixed Into func

* Update (yewstack#5)

* in yewstack org

* Initial implementation using an iterator adaptor to provide a coherent struct to implement Into<VNode> (via From<>) for

* update large table example to demonstrate new .html() method instead of 'for'

* ran cargo fmt

* Add a section for project templates to the README

* Change org to YewStack

* Implement FromIterator instead of wrapping iterator

* remove dead code

* ran fmt

* Add extend method to Classes

* change to union

* renamed union back to extend

* removed unused import of RangeFull

* update

* Fix touch events (yewstack#656)

* Update changelog for v0.9 release (yewstack#657)

* Implement Debug for ChildRenderer<T> (yewstack#655)

* Implement Debug for ChildRenderer<T>

* fix formatter type lifetime

* remove fmt

* cargo fmt

* Emit initial route to router subscribers (yewstack#634)

* Fix typo in RenderService (yewstack#658)

* Add From<&String> for Classes implementation

* @jstarry feedback

- cargo fmt
- rename DEDICATED_WORKERS_* to REMOTE_AGENTS_*
- remove unrelated changes

* TypeId ask key instead &str

* Remove .gitignore changes

* Update agent.rs

* Update agent.rs

* Fix merge conflict
hgzimmerman pushed a commit that referenced this pull request Jun 30, 2020
* Update run instructions

`python3 -m http.server --directory` flag was added in Python 3.7.
Change instructions to cd into static and skip the flag instead -
makes it work with earlier Pythons too.

* Add visual feedback for button click

The minimal example has a button, but clicking it does nothing. This
makes it hard to tell whether the example works or not.

This adds a label that is update when the button is clicked.

* Small improvements to crm example

* Add a heading to each scene to make it more obvious what the page is
for.

* Improve layout of input form by stack the inputs vertically.

* Add a little space between entries when displaying the list.

* Add a hint to the Description input that Markdown can be used.

* Add an explanation to the file_upload example

* Clarify purpose of var in fragments example

* Improve futures_wp example

* Add a second button that demonstrates an unsuccessful fetch.

* Render the markdown document (since we're fetching markdown after
all).

* Remove vague comment that's not really helping.

* Improve inner_html example

* Include a textual explanation of what the example is doing.

* Run cargo fmt

* Remove 'static lifetime for constant

* Improve suggestion in inner_html example

* move markdown.rs to a common crate

* add description to common Cargo.toml

* PR feedback

* PR feedback

* remove static lifetime annotation
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.

2 participants