-
Notifications
You must be signed in to change notification settings - Fork 0
Concepts: code forward
Code-forward lets a page fire requests and apply config before double-meh (or your app) has
finished loading, then adopts the results seamlessly — the network never waits on
script-download → parse → execute. It is driven by a single global, globalThis.__doubleMeh.
import io from 'double-meh'; // installs code-forward automaticallyBefore the library loads, __doubleMeh is a plain command queue. An inline <head> script pushes to
three arrays:
<script>
window.__doubleMeh = window.__doubleMeh || {};
var dm = window.__doubleMeh;
// 1. Fire the request NOW and hand the promise over to be adopted:
(dm.arrived = dm.arrived || []).push(['/api/me', fetch('/api/me')]);
// 2. Register interest in an in-flight key (dedupe a request made elsewhere):
(dm.inFlight = dm.inFlight || []).push('/api/config');
// 3. Queue setup to run once io is live:
(dm.setup = dm.setup || []).push(function (io) {
io.cache.attach();
});
</script>When double-meh loads it drains the queue — setup callbacks run with io, inFlight keys are
registered on track, and each arrived [target, response] pair is adopted (into
track for in-flight sharing and into cache for durability). Your normal call then
resolves from the early fetch instead of hitting the network again:
import io from 'double-meh';
const me = await io.get('/api/me'); // resolves from the <head> fetch — no second requestAfter draining, __doubleMeh becomes the live io handle (Object.assign(dm, io)), and keeps
dm.use(fn), dm.fly(target), and dm.arrived(target, response) live so late deliveries still land.
Installation fires a one-time event: io.on('ready', () => …).
Guides
Concepts
Services
Modules
- fetch transport
- keys & URLs
- helpers
- records
- sse
- storage backends
- compression encoders
- Service Worker integration
Cookbook