Make a way to send and receive events

Open
#5 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
api, frontend

Research direction

Start by locating IframeSyncClient and reading the existing state-synchronization path. Determine how messages are transported and represented, then define dispatchEvent, addEventListener, and removeEventListener around that mechanism; done means named events can carry JSON-serializable objects between iframes without implying native Event support.

Written by the indexing model from the issue text.

Description

In addition to just keeping state synchronized, it was also be useful in some cases to be able to broadcast events of a more ephemeral nature. State should be used in most cases, and especially if late-joining clients need to be given the full state, but imagining a case where one iframe wants to record actions taken in another during a "record" mode, having those transmitted as evens would be useful.

The idea is to add methods to IframeSyncClient:

  • dispatchEvent for sending events
  • addEventListener for subscribing to events
  • removeEventListener for unsubscribing to events, you'll have to pass in the function previously sent in

I think we would specify an event name and object as 2 parameters. Also, native Event objects aren't going to be JSON serializable, so we shouldn't indicate or imply in the code or the demo that that is how this should be used.

Dominant language
JavaScript
Stars
0
Forks
2
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mieweb/iframe-sync

All issues in mieweb/iframe-sync

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.