You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Official Apps for the Agora Interactive Whiteboard.
Installation:
If you don't have pnpm installed:
npm i -g pnpm
Clone or fork this project, at project root run:
pnpm i
pnpm build-all
Environment
By default the playground demo uses a shared Agora Whiteboard account.
We recommend you use your own. Please register a new account and create a new env file packages/playground/.env.local. See packages/playground/.env.example for reference.
Development
pnpm dev
Create A New App
pnpm create-app
Useful Context APIs
Replayable Synced Storages
Storage that synced across clients. Operations on storages are kept which can be replayed.
// Create a storage under "counter" namespace with default value.// You can create multiple storages under the same namespace.// They will share the same synced storage.conststorage1=context.createStorage("counter",{count: 1});// Access statesconsole.log(storage1.state.count);// 1// Listen to state changesconststorage1StateListenerDisposer=storage1.on("stateChanged",diff=>{if(diff.count){console.log(diff.count.newValue,diff.count.oldValue);}});constsea={a: 1,b: false,};// Only writable user can setStateif(context.isWritable){// Similar to React setState, unchanged values will be filtered by a root-level shallow-compare.storage1.setState({count: 2,disabled: true,// Note that `setState` only performs root-level shallow-compare.// Object `sea` will be compared with `===`.// Keys of `sea` will not be compared!
sea,});}// Remember to remove unused listener latercontext.emitter.on("destroy",()=>{storage1StateListenerDisposer();});context.emitter.on("destroy",()=>{stateListenerDisposer();});
Replayable Client Messaging
Messaging between clients. Note that client will also receive the message sent by itself.