-
Notifications
You must be signed in to change notification settings - Fork 60
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
Fix some infinite loops #187
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh this is awesome! Is it possible to fix this in encode/decode
layer as well? Maybe I'm testing this wrong but I still get an infinite loop if I try passing in something like this:
const props = { onPress, title: "This is a button", onPress: () => console.log("click") };
const button = root.createComponent('Button', {...props, self: props});
@vividviolet thanks for the note about encoding — I had that in a locally-applied change but I didn't bring it into this branch, will get it done. Decoding should not have any need for this, since the self-referencing structures will be stripped out during encoding. |
66e8786
to
b593447
Compare
This PR prevents a few infinite loops that could happen in
@remote-ui
packages related to iterating over potentially self-referencing structures. This came up in a few different places:@remote-ui/core
, we try to "hot swap" function properties so that updates to functions need to be sent over the RPC bridge less often. This "hot swapping" is done recursively for props that are objects or arrays.@remote-ui/rpc
, we provide aretain
andrelease
method that will iterate through deeply nested objects to retain all nested functions.