Created
October 19, 2018 21:50
-
-
Save LayZeeDK/f7d95d4d16dff552cbaa0ba1fc0e2796 to your computer and use it in GitHub Desktop.
Search repository implementation for search BLoC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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