Skip to content

Commit

Permalink
feat(search): add search state
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbeau committed Feb 22, 2019
1 parent a772f95 commit 58a6431
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/integration/src/lib/search/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './search.state';
export * from './search-results-tool';
export * from './search.module';
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Component } from '@angular/core';

import { Register } from '@igo2/context';

import { SearchResultsToolOptions } from './search-results-tool.interface';

@Register({
name: 'searchResults',
title: 'igo.integration.tools.searchResults',
Expand Down
28 changes: 28 additions & 0 deletions packages/integration/src/lib/search/search.state.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Injectable } from '@angular/core';

import { EntityStore } from '@igo2/common';
import { SearchResult, SearchSourceService, SearchSource } from '@igo2/geo';

/**
* Service that holds the state of the search module
*/
@Injectable({
providedIn: 'root'
})
export class SearchState {
/**
* Store that holds the search results
*/
public store: EntityStore<SearchResult> = new EntityStore<SearchResult>([]);

/**
* Search types currently enabled in the search source service
*/
get searchTypes(): string[] {
return this.searchSourceService
.getEnabledSources()
.map((source: SearchSource) => (source.constructor as any).type);
}

constructor(private searchSourceService: SearchSourceService) {}
}

0 comments on commit 58a6431

Please sign in to comment.