liveBook · Manning

Decorator

A decorator is a programming-language construct that adds metadata or behavior to, or transforms, a program declaration, often a function or class.

How 7 Manning books explain it

Essential TypeScript 5, Third Edition

A decorator function is a function invoked when a decorator is applied and returns the replacement class feature.

How it is used
Transforms class features without editing their implementations and describes application building blocks in Angular.
How deep it goes
Works through method replacements, context data, generic constraints, class type limitations, factories, stacking order, and shared state.
Examples
Uses a timed method, a serializing subclass, stacked message decorators, accumulated timing data, and Angular module and component declarations.
What you can do after
Build it from scratch to wrap methods, configure each application, and recognize a class decorator’s TypeScript type limitation.

Read how Essential TypeScript 5, Third Edition explains decorator →

Python How-To

A decorator is a callable that modifies or extends the behavior of another callable or class without changing its underlying definition.

How it is used
Extracts shared behavior such as execution-time logging from multiple functions without adding it to each function body.
How deep it goes
Builds and dissects a function decorator as a closure, including argument forwarding, return values, and metadata preservation; defers full closure theory.
Examples
Demonstrates execution-time logging and metadata inspection, then proposes timing CSV-file and SQLite data operations.
What you can do after
Build it from scratch to add reusable logging while preserving arguments, return values, and function metadata.

Read how Python How-To explains decorator →

The Well-Grounded Python Developer: How the pros use Python and Flask

A Python decorator is a callable construct that extends or modifies a function or method without changing its source definition.

How it is used
Uses decorators to preserve direct attribute access while adding coordinate checks, and to add timing around a function call.
How deep it goes
Works through property getters and setters plus a hand-written timing wrapper, without developing an exhaustive account of decorator behavior.
Examples
Shows a rectangle coordinate property and a timing decorator applied to a delayed task.
What you can do after
Apply it via Python’s `@property` and setter decorators to manage coordinates, or write a wrapper to time a function.

Read how The Well-Grounded Python Developer: How the pros use Python and Flask explains decorator →

Django in Action

A decorator is a Python language construct that associates additional behavior or metadata with a function or class.

How it is used
Turns Django view functions into API endpoints while attaching HTTP methods and endpoint configuration.
How deep it goes
Explains decorator syntax, route configuration, request flow, and registration, but does not descend into decorator implementation internals.
Examples
Uses a RiffMates hello endpoint and shows Router-to-NinjaAPI-to-Django URL registration.
What you can do after
Apply it via Django Ninja to build routed API endpoints with method, schema, naming, and authentication configuration.

Read how Django in Action explains decorator →

The Joy of JavaScript

A wrapper-like construct that augments method behavior without changing the method's core implementation.

How it is used
Separates cross-cutting behavior from business logic through dynamically intercepted method calls.
How deep it goes
Explains object specifications, before-and-after actions, higher-order wrappers, and Proxy/Reflect wiring, but not decorator syntax.
Examples
Demonstrates Counter validation, credential tracing, password obfuscation, and composition of nested proxies.
What you can do after
Apply validation, tracing, logging, or return-value enhancement without modifying the decorated object’s business methods.

Read how The Joy of JavaScript explains decorator →

Build Python Web Apps with Streamlit

A decorator is a Python construct that modifies or extends a function or class by wrapping it with additional behavior.

How it is used
Applies caching and popup-dialog behavior to Streamlit functions without rewriting their core data-loading or rendering logic.
How deep it goes
Defines decorators through two working Streamlit examples, but does not explain decorator implementation internals.
Examples
Uses @st.cache_data on load_data and @st.dialog on a drilldown function displaying main and comparison dataframes.
What you can do after
Apply Streamlit decorators to cache data-loading results and render interactive drilldown content in modal dialogs.

Read how Build Python Web Apps with Streamlit explains decorator →

Pro Angular 16

A decorator is a language construct that attaches metadata or behavior to a class or other declaration.

How it is used
Identifies an Angular class as a component and configures how its generated content enters the page.
How deep it goes
Defines metadata properties and traces selector matching to a custom element, while deferring further runtime details.
Examples
Uses AppComponent with app-root, app.component.html, and app.component.css in a todo application.
What you can do after
Apply it via Angular to configure a component class and connect it to an HTML element.

Read how Pro Angular 16 explains decorator →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.