Steve Bennett
Steve Bennett

Reputation: 125995

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.

Upvotes: 1

Views: 45

Answers (1)

Georg
Georg

Reputation: 5771

There is no strict definition of a programming pattern, so something is a programming pattern as soon as someone declares it to be one.

Therefore, I guess all that the documentation was trying to tell was that the class for these ports encapsulates a delay (hence, the quotes). Encapsulating a delay is a common pattern.

Upvotes: 2

Related Questions