When using React, state variables can be created like this:
const SomeComponent = ({ someProp }) => {
const [value, setValue] = useState<boolean>(false);
}
I wonder if there is a similar way to achieve the spread of a tuple within an Angular component's members.
For instance:
@Directive({
selector: '[appDirective]'
})
export class AppDirective {
[value, observable] = createState<boolean>(false);
}
The issue here is that [value, observable]
is not valid syntax. While replacing it with
a = createState<boolean>(false)
does work, I'm interested in finding a method to expand the tuple into two separate member variables of the directive.
It's worth noting that createState
returns [BehaviorSubject<T>, Observable<T>]
.