lundi 27 novembre 2023

Is a "delayed reference" a known programming pattern?

I'm trying to understand JZZ's API.

One of the pecularities is after you obtain a port (a place to send MIDI instructions to), you can do this:

const a = port.noteOn(0, 'C5', 127); // plays note immediately, a is Promise that returns port
const b = port.wait(500); // b is a Promise that returns an object like port

port.noteOn(0, 'E5', 127); // plays note immediately
b.noteOn(0, 'G5', 127); // plays note in 500ms

The documentation says:

wait()

object.wait(delay) - returns a "delayed reference" of the object.

delay is the timeout in microseconds.

Is this "delayed reference" a known programming pattern? I haven't come across it.

Aucun commentaire:

Enregistrer un commentaire