1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/src/lib/services/favorites-service.ts

38 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-11-29 16:06:08 +01:00
import { IUnleashConfig } from '../types/option';
import { IUnleashStores } from '../types/stores';
import { Logger } from '../logger';
import {
IFavoriteFeatureKey,
IFavoriteFeaturesStore,
} from '../types/stores/favorite-features';
import { IFavoriteFeature } from '../types/favorites';
export class FavoritesService {
private config: IUnleashConfig;
private logger: Logger;
private favoriteFeaturesStore: IFavoriteFeaturesStore;
constructor(
{
favoriteFeaturesStore,
}: Pick<IUnleashStores, 'favoriteFeaturesStore'>,
config: IUnleashConfig,
) {
this.config = config;
this.logger = config.getLogger('services/favorites-service.ts');
this.favoriteFeaturesStore = favoriteFeaturesStore;
}
async addFavoriteFeature(
favorite: IFavoriteFeatureKey,
): Promise<IFavoriteFeature> {
return this.favoriteFeaturesStore.addFavoriteFeature(favorite);
}
async removeFavoriteFeature(favorite: IFavoriteFeatureKey): Promise<void> {
return this.favoriteFeaturesStore.delete(favorite);
}
}