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

Third-party components embedding #90

Open
therustmonk opened this issue Jan 7, 2018 · 6 comments
Open

Third-party components embedding #90

therustmonk opened this issue Jan 7, 2018 · 6 comments
Labels
feature-request A feature request

Comments

@therustmonk
Copy link
Member

According to #83 we need a capability to embed third-party components which lives in own lifecycle, like Ace.

@Boscop
Copy link

Boscop commented May 16, 2018

I'm looking forward to this. My use case is: I'm writing a game with the unrust webgl engine, and want to have a HUD GUI overlay based on html with yew (also a chat text field etc.) so I need two way communication between the yew app and the wasm game..
What would be the best way to do this? Using wasm imported/exported functions for rpc?

@samuelvanderwaal
Copy link
Contributor

Missing label:

  • feature

@tieje
Copy link
Contributor

tieje commented Feb 19, 2023

@hamza1311 , if this is not been solved, can you please assign this ticket to me?
Loosely related to #135

@hamza1311
Copy link
Member

Don't portals solve this? I'm not sure what the solution here is. Do you have anything in mind, @tieje?

CC: @WorldSEnder

@tieje
Copy link
Contributor

tieje commented Feb 21, 2023

Don't portals solve this? I'm not sure what the solution here is. Do you have anything in mind, @tieje?

CC: @WorldSEnder

I don't know. Sorry, but I am still yet a learner.

@WorldSEnder
Copy link
Member

Portals can get you there, to some degree. You could for example render something akin to

// Create your third-party component somehow, probably by calling to JS
// Should not be in the view function directly, but in use_state or the component's create
let third_party_element: web_sys::Element = todo!();
// Now, in the view function you can use a portal to let yew handle the children of that element
// These could be for example slotted
let portal_to_children = yew::html::create_portal(html! {
    <>
        <p slot="some-slot">{"I will be rendered as a child of third_party_element"}</p>
        <p slot="some-other-slot">{"E.g. 'slot' can be used with web components"}</p>
    </>
}, third_party_element.clone());
// Render both the original element, and the portal
html! {
<> 
    {portal_to_children}
    {VDom::VRef(third_party_element.into())}
</>
}

Note: I haven't thought about event propagation/bubbling with the above, but I think it should work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature request
Projects
None yet
Development

No branches or pull requests

7 participants