-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker.js
More file actions
36 lines (31 loc) · 1.1 KB
/
worker.js
File metadata and controls
36 lines (31 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import {h} from 'vue';
import { createEndpoint, retain } from "@remote-ui/rpc";
// For convenience, this library re-exports several values from @remote-ui/core, like createRemoteRoot
import {
createRenderer,
createRemoteRoot,
createRemoteVueComponent,
} from '@remote-ui/vue';
// a host component — see implementation below for getting strong
// typing on the available props.
import Counter from './remote/Counter.vue'
import { Button, Div } from './remote/components';
console.log(Counter);
// const RemoteButton = createRemoteVueComponent('Button');
// Assuming we get a function that will communicate with the host...
const renderUI =(receiver) => {
retain(receiver)
const remoteRoot = createRemoteRoot(receiver, {
components: ['Button', 'Div'],
});
const {createApp} = createRenderer(remoteRoot);
createApp({
render() {
return h(Div, {}, () => ['btn testing', h(Button, {onPress: ()=> console.log('testing')}, 'testing here')]);
},
}).mount(remoteRoot);
remoteRoot.mount()
}
const endpoint = createEndpoint(self);
endpoint.expose({ renderUI });
// at the here