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

Is it possible to use a callback in a JSON type? #182

Open
buxbunny110 opened this issue Jun 14, 2024 · 2 comments
Open

Is it possible to use a callback in a JSON type? #182

buxbunny110 opened this issue Jun 14, 2024 · 2 comments

Comments

@buxbunny110
Copy link

There are many components in react that are using callback functions inside objects, it seems it's not working with web component JSON format, which is in fact expectable since it's just text, and it can't understand what is the function in the JSON. but would be really nice if we could use function as a object param like this.

    <web-app
      obj-prop='{ "very": "object", "such": "wow!", "callback": "myFunction:function"}'
    >
    </web-app>

is there any other way other than using the function param only as top level param?

@wataruoguchi
Copy link

I think what you want to achieve is communication between web components or with a web component. I would use something like Custom Event or Broadcast Channel to communicate inside/outside the component, just like what you would do with iframes.

https://wataruoguchi.github.io/poc-spa-gh-pages/ uses runneljs, a Broadcast Channel based library, to demonstrate that the two web components are communicating each other by displaying "Total Count". I hope it's helpful.

@mahmoudmoravej
Copy link

I think they need to parse json object in the same way they're parsing the parameters. So, any function prop inside json will be parsed and mapped correctly.

Also, they can do a better job in how defining R2WCOptions<HeaderProps> to not need to pass string values for property types. So: instead of onClick: 'function' we will have onClick: WcTypes.Function.

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

No branches or pull requests

3 participants