Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Usecase : who to pass listener function to Component using marko path router using Router.renderSync #17

Open
anupdineout opened this issue Jun 7, 2017 · 1 comment

Comments

@anupdineout
Copy link

anupdineout commented Jun 7, 2017

how to pass data parent event function who can get data emitted by child component in Router.renderSync used in your Demo Project . Who to pass data to component and Because we are appending

  const self = this
  const state = self.state
  const routes = [
    { path: '/', component: homeComponent },
    { path: '/**', component: notFoundComponent },
    { path: '/listing', component: listingComponent }
  ]
  const render = Router.renderSync({
    routes: routes,
    initialRoute: state.currentRoute
  })

  const router = this.router = render
    .appendTo(this.getEl('router-container'))
    .getComponent()

What I need

example :-
in Parent App component

class {
clickHomePage (){

}

}

in child component

Class {
emitDataToParent(){
this.emit("clickHome", {page :"home"})
}
}

@ctdio
Copy link
Owner

ctdio commented Jun 7, 2017

Hey, sorry I saw the issue you created in Marko (marko-js/marko#725) before this one. Unfortunately, this module does not support emitting events from child components to the parent. Like I said in the other issue, your best bet for intercommunication for components rendered via the router would be to use something like redux or maybe some sort of event bus that components share.

A feature like this will probably require quite a few changes to how the router functions. I'll consider adding this feature in future releases.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants