Skip to content

Commit c69b504

Browse files
authored
Fix/localfilter 56 (#62)
* Now, if you are running demo:start and you touch src code, demo app is recompiled and reloaded * README updated with a simple gif * supress WARNING in Circular dependency detected * localfilter fixed. 1.0.0-rc.12 Closes #56.
1 parent 4dfde2a commit c69b504

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export class AuthorsComponent {
153153
Filter resources with `attribute: value` values. Filters are used as 'exact match' (only resources with attribute value same as value are returned). `value` can also be an array, then only objects with same `attribute` value as one of `values` array elements are returned.
154154

155155
```javascript
156-
let authors = authorsService.all(
156+
let authors$ = authorsService.all(
157157
{
158158
localfilter: { name: 'xx' }, // request all data and next filter locally
159159
remotefilter: { country: 'Argentina' } // request data with filter url parameter
@@ -166,7 +166,7 @@ let authors = authorsService.all(
166166
From this point, you only see important code for this library. For a full example, clone and see demo directory.
167167

168168
```javascript
169-
let author = authorsService.get('some_author_id');
169+
let author$ = authorsService.get('some_author_id');
170170
```
171171

172172
#### More options? Include resources when you fetch data (or save!)

demo/app/authors/components/authors.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ export class AuthorsComponent {
1616
) {
1717
authorsService.all(
1818
// { include: ['books', 'photos'] }
19+
// {
20+
// localfilter: {
21+
// name: 'y', // authors with a `y` character on name
22+
// date_of_birth: /^2016\-.*/ // we can use regular expresions too :)
23+
// }
24+
// }
1925
)
2026
.subscribe(
2127
authors => {

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-jsonapi",
3-
"version": "1.0.0-rc.11",
3+
"version": "1.0.0-rc.12",
44
"description": "JSON API library for Angular",
55
"module": "ngx-jsonapi/@ngx-jsonapi/ngx-jsonapi.es5.js",
66
"es2015": "ngx-jsonapi/@ngx-jsonapi/ngx-jsonapi.js",

src/service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ export class Service<R extends Resource = Resource> extends ParentResourceServic
424424
fc_success,
425425
fc_error,
426426
tempororay_collection: ICollection<R>,
427-
cached_collection: ICollection,
427+
cached_collection: ICollection<R>,
428428
subject: BehaviorSubject<ICollection<R>>
429429
) {
430430
// SERVER REQUEST
@@ -479,7 +479,7 @@ export class Service<R extends Resource = Resource> extends ParentResourceServic
479479
}
480480
}
481481

482-
subject.next(tempororay_collection);
482+
subject.next(cached_collection);
483483
subject.complete();
484484
this.runFc(fc_success, success);
485485
})

src/services/localfilter.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ export class LocalFilter {
2121
);
2222
} else if (typeof resource.attributes[attribute] === 'string') {
2323
// just a string
24-
return (
25-
resource.attributes[attribute] === localfilter[attribute]
26-
);
24+
return resource.attributes[attribute].includes(localfilter[attribute]);
2725
}
2826
}
2927

@@ -41,5 +39,6 @@ export class LocalFilter {
4139
}
4240
});
4341
}
42+
console.log('y quedó así', dest_collection);
4443
}
4544
}

0 commit comments

Comments
 (0)