Home
Using Smart NgRX
Demo Walkthrough
API
@smarttools/smart-ngrx / Function

assert

This is an internal function documented here for reference by people doing development on this library.

Asserts that a value is true. You should only use one condition at a time. If you are working with a value that should always be true, this is easier than putting if(condition) around what you are going to use the condition for.

Example

instead of this:

let variableWeExpectWilNotBeNullOrUndefined: SomeType;
// somewhere in here we set the variable
if(variableWeExpectWilNotBeNullOrUndefined) {
  return; // or throw an exception or whatever
}
// now use the variable without having to use ? or ! everywhere

do this:

let variableWeExpectWilNotBeNullOrUndefined: SomeType;
// somewhere in here we set the variable
assert(variableWeExpectWilNotBeNullOrUndefined, 'variableWeExpectWilNotBeNullOrUndefined');
// now use the variable without having to use ? or ! everywhere

Presentation

function assert(condition: boolean, context: string): void;

Returns

void

Parameters

NameTypeDescription
condition
boolean

condition to check

context
string

description of what we checked.