We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
const host = new crosscall.Host({ // NEW CALLEE callee: { exampleTopic: { methods: { async exampleMethodAlpha(a) { return a + 1 }, async exampleMethodBravo(a, b) { return a + b } }, events: { exampleEvent: { listen(listener) { window.addEventListener("explosion", listener) }, unlisten(listener) { window.removeEventListener("explosion", listener) } } } } }, // NEW PERMISSIONS permissions: [{ origin: /^http:\/\/localhost:8080$/, allowed: { exampleTopic: { methods: ["exampleMethodAlpha", "exampleMethodBravo"]. events: ["exampleEvent"] } } }] })
The text was updated successfully, but these errors were encountered:
the following is unacceptable
const {callable} = await client.callable const {exampleTopic} = callable.exampleTopic exampleTopic.methods.doCoolThing() exampleTopic.events.coolThing.listen(() => {})
having the methods and events objects under the topic is gross
methods
events
therefore, the following strategy is better
const host = new crosscall.Host({ callee: { methods: { exampleDragonMethods: { async fly(a) { return a + 1 }, async breatheFire(a, b) { return a + b }, async eatPeasants(a, b, c) { return a * b * c } } }, events: { exampleKangarooEvents: { kangarooHopped: { listen(listener) { window.addEventListener("kangarooHopped", listener) }, unlisten(listener) { window.removeEventListener("kangarooHopped", listener) } } } } }, permissions: [{ origin: /^http:\/\/localhost:8080$/, allowedMethods: { exampleDragonMethods: ["fly", "breatheFire", "eatPeasants"] }, allowedEvents: { exampleKangarooEvents: ["kangarooHopped"] } }] }) // later, on the client const {callable} = await client.callable const {exampleDragonMethods} = callable.methods const {exampleKangarooEvents} = callable.events
the downside is that methods and events can never share a topic, they can't live on the same object
meh
Sorry, something went wrong.
const host = new CrosscallHost({ exposures: [{ allowed: /^http\:\/\/localhost\:8\d{3}$/i, forbidden: /\:8989$/i, methods: { dragonMethods: { async fly(a) { return a + 1 }, async breatheFire(a, b) { return a + b }, async eatPeasants(a, b, c) { return a * b * c } } }, events: { kangarooEvents: { kangarooHopped: { listen(listener) { window.addEventListener("kangarooHopped", listener) }, unlisten(listener) { window.removeEventListener("kangarooHopped", listener) } } } } }] } // later, on the client const callable = await client.callable const {dragonMethods} = callable.methods const {kangarooEvents} = callable.events
chase-moskal
No branches or pull requests
The text was updated successfully, but these errors were encountered: