Skip to content

Instantly share code, notes, and snippets.

@LayZeeDK
Created October 19, 2018 21:50
Show Gist options
  • Save LayZeeDK/f7d95d4d16dff552cbaa0ba1fc0e2796 to your computer and use it in GitHub Desktop.
Save LayZeeDK/f7d95d4d16dff552cbaa0ba1fc0e2796 to your computer and use it in GitHub Desktop.
Search repository implementation for search BLoC
import { Injectable } from '@angular/core';
import * as faker from 'faker';
import { of as observableOf } from 'rxjs';
import { delay } from 'rxjs/operators';
import { SearchRepository } from '../../business-logic/search';
@Injectable()
export class AppSearchRepository implements SearchRepository {
async search(query: string) {
if (query == null || query.length === 0) {
return await [];
}
const results = new Array(10).fill(null).map(() => faker.name.findName());
return new Promise<string[]>(resolve => {
setTimeout(() => {
resolve(results);
}, 300);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment