OneOf, And & Or Utilities
Markup comes with additional utilities that work as operators and allows you to check a value from a bunch. This comes in form of and, or, and oneOf utilities.
oneOf
The oneOf works like the is and isNot utilities but instead of checking a one value, it checks many.
1const [status, setStatus] = state('pending')2 3html`${when(4 oneOf(status, ['pending', 'idle']),5 html`<p>loading...</p>`,6 html`<p>done</p>`7)}`It takes the value/state you want to check and an array of values to check against. The utility simply checks the value exactly.
and
The and utility works like the && (Logical AND). It will return true only if all values are TRUTHY.
1html`${when(2 and(loadingTodos, noTodos),3 html`<p>loading...</p>`,4 html`<p>done</p>`5)}`You can list any amount of values for the check:
and(value1, value2, ..., valueN)
or
The or utility works like the || (Logical OR). It will return true only if at least one of the values are TRUTHY.
1html`${when(2 or(loadingTodos, noTodos),3 html`<p>loading...</p>`,4 html`<p>done</p>`5)}`You can list any amount of values for the check:
or(value1, value2, ..., valueN)