cross_tab 0.1.2 copy "cross_tab: ^0.1.2" to clipboard
cross_tab: ^0.1.2 copied to clipboard

Coordinate the browser tabs of a Flutter Web app: send typed messages between them, know how many are open, and elect exactly one to do the work.

0.1.2 #

Actually fixes the README's opening example.

0.1.1 said it had fixed this and had not. The edit was made in the working tree and never staged, so that release changed only the version and the changelog — the broken snippet went out again, now with a note claiming it was gone. Verifying that a fix landed is part of the fix, and skipping it turned a small error into a false claim.

The opening example read if (p.isLeader) startPolling() else stopPolling();, which is missing the semicolon before else and does not compile.

0.1.1 #

  • Fixes the README's opening example, which did not compile. It read if (p.isLeader) startPolling() else stopPolling(); — missing the semicolon before else — so the first thing anyone copied out of this package was a syntax error. The corrected snippet was checked through the analyser rather than by eye.

0.1.0 #

Initial release: cross-tab coordination for Flutter Web.

  • CrossTab.open(name) joins every tab of your app sharing that name.
  • Leader election. Exactly one tab is elected to do work that must happen once — polling, a socket, a notification — and leadership moves when that tab closes. The oldest tab leads, with the id as a tiebreak so tabs opened in the same microsecond still reach the same answer.
  • Presence. count, tabs, leader, isLeader, emitted on change and on subscription. A closed tab says goodbye so the others react immediately; a crashed one is dropped after three missed heartbeats.
  • Messages with a sender id, carrying structure rather than strings. A tab never hears its own.
  • Off the web the package still compiles and behaves as the single instance it is: one tab, always the leader. That is the truthful answer, and it means leader logic needs no if (kIsWeb) around it.

Verified in a real browser: flutter test --platform chrome exercises four tabs agreeing on one leader, the oldest winning, and leadership passing on close — using two BroadcastChannel objects in one document, which see each other exactly as separate tabs do.

0
likes
160
points
--
downloads

Documentation

Documentation
API reference

Publisher

verified publisherjumyn.com

Coordinate the browser tabs of a Flutter Web app: send typed messages between them, know how many are open, and elect exactly one to do the work.

Repository (GitHub)
View/report issues

Topics

#web #broadcastchannel #tabs #leader-election #browser

License

MIT (license)

Dependencies

flutter, web

More

Packages that depend on cross_tab