Skip to content

Commit

Permalink
Remove RxJS compatibility layer with lettable and chainable operators
Browse files Browse the repository at this point in the history
  • Loading branch information
morvans committed Jul 23, 2020
1 parent 183cd77 commit f9f1d6a
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 131 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
"@ngrx/effects": "^9.0.0",
"@ngrx/store": "^9.0.0",
"deep-object-diff": "^1.1.0",
"rxjs": "^6.5.3",
"rxjs-compat": "^6.5.3"
"rxjs": "^6.5.3"
},
"devDependencies": {
"@angular/animations": "^9.0.0",
Expand Down Expand Up @@ -110,7 +109,6 @@
"rimraf": "^2.6.2",
"rollup": "^0.55.1",
"rxjs": "~6.5.0",
"rxjs-compat": "~6.5.0",
"sorcery": "^0.10.0",
"ts-node": "^4.1.0",
"tsickle": "^0.38.1",
Expand Down
3 changes: 1 addition & 2 deletions spec/actions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { async, inject, fakeAsync, TestBed } from '@angular/core/testing';

import {
NgrxJsonApiActionTypes,
ApiPostInitAction,
Expand Down Expand Up @@ -241,6 +239,7 @@ describe('Json Api Actions', () => {
let action = new ApiGetSuccessAction({}, 'testZone');
expect(action.type).toEqual(NgrxJsonApiActionTypes.API_GET_SUCCESS);
expect(action.payload).toEqual({});

});

it('should generate an api read fail action using apiReadFail', () => {
Expand Down
28 changes: 14 additions & 14 deletions spec/effects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
HttpResponse,
} from '@angular/common/http';

import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';

import { cold, hot } from 'jasmine-marbles';

Expand Down Expand Up @@ -43,7 +43,7 @@ describe('NgrxJsonApiEffects', () => {
let actions: Observable<any>;
let api: NgrxJsonApi;
let store: Store<any>;
let mockStoreLet: any;
let mockStorePipe: any;

beforeEach(() => {
TestBed.configureTestingModule({
Expand All @@ -65,11 +65,11 @@ describe('NgrxJsonApiEffects', () => {
api = TestBed.get(NgrxJsonApi);
effects = TestBed.get(NgrxJsonApiEffects);
store = TestBed.get(Store);
mockStoreLet = {
let: function() {},
mockStorePipe = {
pipe: function() {},
};
spyOn(store, 'let');
spyOn(mockStoreLet, 'let');
spyOn(store, 'pipe');
spyOn(mockStorePipe, 'pipe');
});

let resource = {
Expand Down Expand Up @@ -240,8 +240,8 @@ describe('NgrxJsonApiEffects', () => {
actions = hot('-a', { a: localqueryinitAction });
let response = cold('--a', { a: query });
let expected = cold('---b', { b: completed });
store.let.and.returnValue(mockStoreLet);
mockStoreLet.let.and.returnValue(response);
store.pipe.and.returnValue(mockStorePipe);
mockStorePipe.pipe.and.returnValue(response);
expect(effects.queryStore$).toBeObservable(expected);
});

Expand Down Expand Up @@ -298,8 +298,8 @@ describe('NgrxJsonApiEffects', () => {
b: completed2,
c: completed3,
});
store.let.and.returnValue(mockStoreLet);
mockStoreLet.let.and.returnValue(response);
store.pipe.and.returnValue(mockStorePipe);
mockStorePipe.pipe.and.returnValue(response);
expect(effects.queryStore$).toBeObservable(expected);
});

Expand Down Expand Up @@ -329,8 +329,8 @@ describe('NgrxJsonApiEffects', () => {
actions = hot('-a--b', { a: localqueryinitAction, b: removeQueryAction });
let response = cold('--a----b', { a: resource1, b: resource2 });
let expected = cold('---a', { a: completed });
store.let.and.returnValue(mockStoreLet);
mockStoreLet.let.and.returnValue(response);
store.pipe.and.returnValue(mockStorePipe);
mockStorePipe.pipe.and.returnValue(response);
expect(effects.queryStore$).toBeObservable(expected);
});

Expand All @@ -347,8 +347,8 @@ describe('NgrxJsonApiEffects', () => {
actions = hot('-a', { a: localqueryfailAction });
let response = cold('--#', {}, error);
let expected = cold('---b', { b: completed });
store.let.and.returnValue(mockStoreLet);
mockStoreLet.let.and.returnValue(response);
store.pipe.and.returnValue(mockStorePipe);
mockStorePipe.pipe.and.returnValue(response);
expect(effects.queryStore$).toBeObservable(expected);
});

Expand Down
5 changes: 3 additions & 2 deletions spec/pipes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { denormaliseStoreResource } from '../src/utils';

import { TestingModule } from './testing.module';
import { map } from 'rxjs/operators';

describe('Pipes', () => {
let pipe;
Expand Down Expand Up @@ -104,7 +105,7 @@ describe('Pipes', () => {
};
let storeResource = pipe.service
.findOne({ query, fromServer: false })
.map(it => it.data);
.pipe(map(it => it.data));
let denormalised = pipe.transform(storeResource);
denormalised.subscribe(it => {
expect(_.get(it, 'relationships.author.reference')).toBeDefined();
Expand All @@ -117,7 +118,7 @@ describe('Pipes', () => {
};
let storeResource = pipe.service
.findMany({ query, fromServer: false })
.map(it => it.data);
.pipe(map(it => it.data));
let denormalised = pipe.transform(storeResource);
denormalised.subscribe(it => {
expect(_.get(it[0], 'relationships.author.reference')).toBeDefined();
Expand Down
34 changes: 17 additions & 17 deletions spec/selectors.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fakeAsync, inject, TestBed, tick } from '@angular/core/testing';

import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';

import { TestingModule } from './testing.module';
import { Store } from '@ngrx/store';
Expand Down Expand Up @@ -31,7 +31,7 @@ describe('NgrxJsonApiSelectors', () => {
);

beforeEach(() => {
store = store.let(selectNgrxJsonApiDefaultZone());
store = store.pipe(selectNgrxJsonApiDefaultZone());
});

describe('selectStoreResourcesOfType', () => {
Expand All @@ -40,7 +40,7 @@ describe('NgrxJsonApiSelectors', () => {
fakeAsync(() => {
let res;
let sub = store
.let(selectStoreResourcesOfType('Article'))
.pipe(selectStoreResourcesOfType('Article'))
.subscribe(d => (res = d));
tick();
expect(res['1']).toBeDefined();
Expand All @@ -58,7 +58,7 @@ describe('NgrxJsonApiSelectors', () => {
'should get the a single query given a queryId',
fakeAsync(() => {
let res;
let sub = store.let(selectStoreQuery('1')).subscribe(d => (res = d));
let sub = store.pipe(selectStoreQuery('1')).subscribe(d => (res = d));
tick();
expect(res.query).toBeDefined();
expect(res.resultIds).toBeDefined();
Expand All @@ -70,7 +70,7 @@ describe('NgrxJsonApiSelectors', () => {
'should return undefined for unavailable queries',
fakeAsync(() => {
let res;
let sub = store.let(selectStoreQuery('10')).subscribe(d => (res = d));
let sub = store.pipe(selectStoreQuery('10')).subscribe(d => (res = d));
tick();
expect(res).not.toBeDefined();
})
Expand All @@ -83,7 +83,7 @@ describe('NgrxJsonApiSelectors', () => {
fakeAsync(() => {
let res;
let sub = store
.let(selectManyQueryResult('1'))
.pipe(selectManyQueryResult('1'))
.subscribe(d => (res = d));
tick();
expect(res.data[0].id).toEqual('1');
Expand All @@ -96,7 +96,7 @@ describe('NgrxJsonApiSelectors', () => {
fakeAsync(() => {
let res;
let sub = store
.let(selectManyQueryResult('doesNotExist'))
.pipe(selectManyQueryResult('doesNotExist'))
.subscribe(d => (res = d));
tick();
expect(res).toBeUndefined();
Expand All @@ -108,7 +108,7 @@ describe('NgrxJsonApiSelectors', () => {
fakeAsync(() => {
let res;
let sub = store
.let(selectManyQueryResult('55'))
.pipe(selectManyQueryResult('55'))
.subscribe(d => (res = d));
tick();
expect(res.data).toEqual([]);
Expand All @@ -120,7 +120,7 @@ describe('NgrxJsonApiSelectors', () => {
fakeAsync(() => {
let res;
let sub = store
.let(selectManyQueryResult('56'))
.pipe(selectManyQueryResult('56'))
.subscribe(d => (res = d));
tick();
expect(res.data[0]).toBeUndefined();
Expand All @@ -135,7 +135,7 @@ describe('NgrxJsonApiSelectors', () => {
fakeAsync(() => {
let res;
let sub = store
.let(selectOneQueryResult('2'))
.pipe(selectOneQueryResult('2'))
.subscribe(d => (res = d));
tick();
expect(res.data.id).toEqual('1');
Expand All @@ -147,7 +147,7 @@ describe('NgrxJsonApiSelectors', () => {
fakeAsync(() => {
let res;
let sub = store
.let(selectOneQueryResult('doesNotExist'))
.pipe(selectOneQueryResult('doesNotExist'))
.subscribe(d => (res = d));
tick();
expect(res).toBeUndefined();
Expand All @@ -160,7 +160,7 @@ describe('NgrxJsonApiSelectors', () => {
let res;
let err;
let sub = store
.let(selectOneQueryResult('1'))
.pipe(selectOneQueryResult('1'))
.subscribe(d => (res = d), e => (err = e));
tick();
expect(res).toBeUndefined();
Expand All @@ -174,7 +174,7 @@ describe('NgrxJsonApiSelectors', () => {
fakeAsync(() => {
let res;
let sub = store
.let(selectOneQueryResult('55'))
.pipe(selectOneQueryResult('55'))
.subscribe(d => (res = d));
tick();
expect(res.data).toBeNull();
Expand All @@ -188,7 +188,7 @@ describe('NgrxJsonApiSelectors', () => {
fakeAsync(() => {
let res;
let sub = store
.let(selectStoreResource({ type: 'Article', id: '1' }))
.pipe(selectStoreResource({ type: 'Article', id: '1' }))
.subscribe(d => (res = d));
tick();
expect(res.attributes.title).toEqual('Article 1');
Expand All @@ -202,7 +202,7 @@ describe('NgrxJsonApiSelectors', () => {
fakeAsync(() => {
let res;
let sub = store
.let(selectStoreResource({ type: 'Article', id: '100' }))
.pipe(selectStoreResource({ type: 'Article', id: '100' }))
.subscribe(d => (res = d));
tick();
expect(res).not.toBeDefined();
Expand All @@ -216,7 +216,7 @@ describe('NgrxJsonApiSelectors', () => {
fakeAsync(() => {
let res;
let sub = store
.let(
.pipe(
selectStoreResources([
{ type: 'Article', id: '1' },
{ type: 'Article', id: '2' },
Expand All @@ -238,7 +238,7 @@ describe('NgrxJsonApiSelectors', () => {
fakeAsync(() => {
let res;
let sub = store
.let(
.pipe(
selectStoreResources([
{ type: 'Article', id: '100' },
{ type: 'Article', id: '1' },
Expand Down
7 changes: 4 additions & 3 deletions spec/services.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { inject, TestBed } from '@angular/core/testing';

import * as _ from 'lodash';

import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
import { NgrxJsonApiService } from '../src/services';

import { denormaliseStoreResource } from '../src/utils';

import { StoreResource } from '../src/interfaces';
import { TestingModule } from './testing.module';
import { resourceDefinitions } from './test_utils';
import { map } from 'rxjs/operators';

describe('NgrxJsonApiService', () => {
let service: NgrxJsonApiService;
Expand Down Expand Up @@ -74,7 +75,7 @@ describe('NgrxJsonApiService', () => {
let res;
let storeResource = service
.findOne({ query, fromServer: false, denormalise: true })
.map(it => it.data);
.pipe(map(it => it.data));
storeResource.subscribe(it => (res = it));
service.denormaliseResource(storeResource).subscribe(it => {
expect(it).toEqual(res);
Expand Down Expand Up @@ -155,7 +156,7 @@ describe('NgrxJsonApiService', () => {
let res: Array<StoreResource>;
let storeResources: Observable<Array<StoreResource>> = service
.findMany({ query, fromServer: false, denormalise: true })
.map(it => it.data);
.pipe(map(it => it.data));
storeResources.subscribe(it => (res = it));
service.denormaliseResource(storeResources).subscribe(it => {
expect(it).toEqual(res);
Expand Down
2 changes: 0 additions & 2 deletions spec/testing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { NgModule } from '@angular/core';

import { HttpClientModule } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import 'rxjs/add/observable/of';
import 'rxjs/add/observable/throw';

import { StoreModule } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
Expand Down
5 changes: 1 addition & 4 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import {
HttpUserEvent,
} from '@angular/common/http';

import { ErrorObservable } from 'rxjs/observable/ErrorObservable';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/observable/throw';
import { Observable } from 'rxjs';

import {
Document,
Expand Down
Loading

0 comments on commit f9f1d6a

Please sign in to comment.