Skip to content

Commit

Permalink
Add methods for collections, topics and users (#174)
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Turrell-Croft <[email protected]>
  • Loading branch information
Selindek and Thomas Turrell-Croft authored May 31, 2023
1 parent 01572f7 commit e8d5a6a
Show file tree
Hide file tree
Showing 13 changed files with 1,693 additions and 131 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ jobs:
- run: npm ci
- run: npx ng build
# TODO add linting
- run: npx ng test --no-watch --no-progress --browsers=ChromeHeadless
- run: npx ng test --no-watch --no-progress --code-coverage --browsers=ChromeHeadless
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function unsplashConfigFactory(userService: UserService) {
export class AppModule {}
```

### List
### List Photos

Inject the UnsplashService into the constructor of a component.

Expand All @@ -124,15 +124,15 @@ export class ListComponent {

constructor(private unsplash: UnsplashService) {}

list() {
this.unsplash.list({ perPage: 40 }).subscribe((response) => {
photos() {
this.unsplash.photos({ perPage: 40 }).subscribe((response) => {
this.photos = response;
});
}
}
```

### Get
### Get a Photo

Inject the UnsplashService into the constructor of a component.

Expand All @@ -144,8 +144,8 @@ export class GetComponent {

constructor(private unsplash: UnsplashService) {}

get(id: string) {
this.unsplash.get(id).subscribe((response) => {
photo(id: string) {
this.unsplash.photo(id).subscribe((response) => {
this.photo = response;
});
}
Expand Down Expand Up @@ -174,8 +174,8 @@ export class RandomComponent {

constructor(private unsplash: UnsplashService) {}

random() {
this.unsplash.random({ count: 10 }).subscribe((response) => {
randomPhoto() {
this.unsplash.randomPhoto({ count: 10 }).subscribe((response) => {
this.photos = response;
});
}
Expand Down Expand Up @@ -204,8 +204,8 @@ export class SearchComponent {

constructor(private unsplash: UnsplashService) {}

search(query: string) {
this.unsplash.search(query, { perPage: 10 }).subscribe((response) => {
searchPhotos(query: string) {
this.unsplash.searchPhotos(query, { perPage: 10 }).subscribe((response) => {
this.photos = response.results;
});
}
Expand All @@ -214,14 +214,16 @@ export class SearchComponent {

### Triggering a download

Inject the UnsplashService into the constructor of a component.

Example:

```TypeScript
export class DownloadComponent {

constructor(private unsplash: UnsplashService) {}

download(photo: Photo) {
downloadPhoto(photo: Photo) {
this.unsplash.download(photo).subscribe();
}
}
Expand Down
3 changes: 2 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"polyfills": [
"zone.js",
"zone.js/testing"
]
],
"karmaConfig": "projects/ngx-unsplash/karma.conf.js"
}
}
}
Expand Down
Loading

0 comments on commit e8d5a6a

Please sign in to comment.