krakenjs / zoid

Cross domain components
Apache License 2.0
2.03k stars 248 forks source link

Callback when props change inside iframe #111

Closed ps-video-player closed 7 years ago

ps-video-player commented 7 years ago

I'm passing down state from the iframe to my component using xcomponent. I'm using updateProps to then modify the props. These are getting passed down to the component, but I don't know when they change so I can't react to them. Is there a hook on child window to register a callback for when updateProps is called from the parent?

bluepnume commented 7 years ago

Absolutely, you can do:

window.xchild.onProps(props => {
    ...
});
ps-video-player commented 7 years ago

Just what I was looking for! I might have completely missed it, but is xchild documented anywhere? Or is the code the best place to look currently?

bluepnume commented 7 years ago

Yeah, it's something I need to get round to documenting. Glad it works for you though!