liveBook · Manning

Push model

As explained in JavaScript in Depth

A data-processing model in which an upstream source delivers data to downstream processing without each item being explicitly requested.

A push model lets the producer initiate data flow while the consumer reacts. Data travels through zero or more transforms, with the producer controlling the pipeline's rhythm. section 10.1

Use these distinctions when reasoning about a streaming pipeline:

  • Push is eager: the producer moves data when it becomes available; pull is lazy: the producer waits for a consumer request. section 10.1
  • The model is independent of payload type: bytes, objects, strings, and numbers can all flow through a JavaScript stream. section 10.1
  • Push does not necessarily mean uncontrolled speed; a stream can pace its producer through backpressure. section 10.1 section 10.6.3
  • Ignoring backpressure lets an internal queue grow without bound, increasing resident memory until processing finishes or the process is killed. section 10.6.3

A push stream consumed with pull syntax

A Node.js Readable can be consumed with `for await (const chunk of readable)`. The loop pulls one chunk at a time, but the Readable remains internally push-driven: its event mechanism fills a buffer, and backpressure pauses the source when that buffer fills. section 10.5.3

Figure 10.1 The fundamental flow of data through a stream is the same regardless of the specific implementation. A producer provides chunks of data that flow through a series of transforms and on to a consumer.

Trace data from producer through transforms to consumer in the pipeline diagram. section 10.1

How JavaScript in Depth covers it

How deep it goes
Defines producer-controlled flow, compares pull semantics, and traces buffering and backpressure without developing a complete stream API tutorial.
Examples
Uses Node.js Readables, event-driven streams, async iteration, fast and slow consumers, and memory-growth measurements.
What you can do after
Diagnose/debug with it by identifying producer control, buffer growth, and ignored backpressure in streaming pipelines.
How it connects
Connects producers, consumers, transforms, pipelines, pull models, backpressure, async iteration, and internal buffering.

Also explained in

Compare how 5 books explain push model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of JavaScript in Depth. The section links point to the parts of the book it draws on.