Created
August 16, 2022 17:44
-
-
Save gyenabubakar/c26a07bbe2c2481b993f7b0891f71602 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// since Child is wrapped inside VideoCallFunctionProvider, | |
// we can access the context value here | |
import { get } from '.VideoCallFunctionProvider.svelte'; | |
const { triggerVideoCall } = get() | |
</script> | |
<button on:click={() => triggerVideoCall()}> | |
Call John Doe | |
</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import VideoCallFunctionProvider from '.VideoCallFunctionProvider.svelte'; | |
import Child from 'Child.svelte' | |
</script> | |
<VideoCallFunctionProvider> | |
<!-- you'd wrap all dashboard stuff here --> | |
<Child /> | |
</VideoCallFunctionProvider> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script context="module"> | |
export const KEY = 'video-call-func-ctx'; | |
export const get = getContext(KEY); | |
</script> | |
<script> | |
import { setContext, getContext } from 'svelte'; | |
function triggerVideoCall() { | |
// ... logic here | |
} | |
setContext(KEY, { triggerVideoCall }); | |
</script> | |
<!-- You may put the video call markup here --> | |
<slot /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment