mapFromOptionalBlock
mapFromOptionalBlock<
T,R>(block):T|null
Defined in: projects/ngx-signal-schema/src/lib/structure/optional-block.ts:102
Maps an OptionalBlock to its data if it is enabled, otherwise returns null. Useful for mapping form values back to domain models or DTOs.
Type Parameters
Section titled “Type Parameters”T
R = boolean
Parameters
Section titled “Parameters”OptionalBlock<T, R>
The OptionalBlock to map.
Returns
Section titled “Returns”T | null
The data if enabled, null otherwise.
Example
Section titled “Example”const block = { meta: { enabled: true }, data: { name: 'John' } };const data = mapFromOptionalBlock(block); // { name: 'John' }
const disabledBlock = { meta: { enabled: false }, data: { name: 'John' } };const noData = mapFromOptionalBlock(disabledBlock); // null