Within my Angular project, there exists an observable object with the following structure:
export interface FavoritesResponse {
wallet: boolean;
deposit: boolean;
withdraw: boolean;
transfer: boolean;
exchange: boolean;
ticket: boolean;
account: boolean;
}
My goal is to create an array
from this object that only includes properties with a value of true
.
For instance, if my favorites object is as follows:
favorites$ = {
wallet: true,
deposit: true,
withdraw: false,
transfer: false,
exchange: false,
ticket: true,
account: true
}
I aim to transform my enabledFavorites$ to match this format:
enabledFavorites$ = [
wallet,
deposit,
ticket,
account
]
In other words, convert it into an array containing only the keys that held a value of true. How can I achieve this? While I believe the solution involves utilizing an rxjs pipe and map, the exact implementation eludes me.