Skip to content

Commit

Permalink
feat(store): add provideStore and provideState functions for standalo…
Browse files Browse the repository at this point in the history
…ne APIs (#3539)

Closes #3526
  • Loading branch information
brandonroberts authored Aug 23, 2022
1 parent 63df014 commit 5639c1e
Show file tree
Hide file tree
Showing 43 changed files with 1,116 additions and 226 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ jobs:
- write_master_hash
- run:
name: Run Affected E2E Tests
command: yarn nx affected --target=e2e --base=$(cat ~/project/master.txt) --head=$CIRCLE_SHA1 --parallel --exclude=docs-app
command: yarn nx affected --target=e2e --base=$(cat ~/project/master.txt) --head=$CIRCLE_SHA1 --parallel=1 --exclude=docs-app

deploy:
<<: *run_in_node
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@ example-dist/
*.tgz
modules/*/schematics-core/testing
!modules/schematics-core/testing

.angular
121 changes: 121 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,127 @@
"schematics": {},
"tags": []
},
"standalone-app": {
"projectType": "application",
"root": "projects/standalone-app",
"sourceRoot": "projects/standalone-app/src",
"prefix": "ngrx",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/projects/standalone-app",
"index": "projects/standalone-app/src/index.html",
"main": "projects/standalone-app/src/main.ts",
"polyfills": "projects/standalone-app/src/polyfills.ts",
"tsConfig": "projects/standalone-app/tsconfig.app.json",
"assets": [
"projects/standalone-app/src/favicon.ico",
"projects/standalone-app/src/assets"
],
"styles": ["projects/standalone-app/src/styles.css"],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "projects/standalone-app/src/environments/environment.ts",
"with": "projects/standalone-app/src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "standalone-app:build:production"
},
"development": {
"browserTarget": "standalone-app:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "standalone-app:build"
}
},
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": [
"projects/standalone-app/**/*.ts",
"projects/standalone-app/**/*.html"
]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"outputs": ["coverage/projects/standalone-app"],
"options": {
"jestConfig": "projects/standalone-app/jest.config.ts",
"passWithNoTests": true
}
}
},
"tags": []
},
"standalone-app-e2e": {
"root": "projects/standalone-app-e2e",
"sourceRoot": "projects/standalone-app-e2e/src",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "projects/standalone-app-e2e/cypress.json",
"devServerTarget": "standalone-app:serve:development"
},
"configurations": {
"production": {
"devServerTarget": "standalone-app:serve:production"
}
}
},
"lint": {
"builder": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["projects/standalone-app-e2e/**/*.{js,ts}"]
}
}
},
"tags": [],
"implicitDependencies": ["standalone-app"]
},
"store": {
"projectType": "library",
"root": "modules/store",
Expand Down
2 changes: 1 addition & 1 deletion modules/store/spec/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ describe('ngRx Integration spec', () => {

router.navigateByUrl('/feature-path').catch((err: TypeError) => {
expect(err.message).toBe(
'StoreModule.forRoot() called twice. Feature modules should use StoreModule.forFeature() instead.'
'The root Store has been provided more than once. Feature modules should provide feature states instead.'
);
done();
});
Expand Down
2 changes: 1 addition & 1 deletion modules/store/spec/store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ActionReducer,
Action,
} from '../';
import { StoreConfig } from '../src/store_module';
import { StoreConfig } from '../src/store_config';
import { combineReducers } from '../src/utils';
import {
counterReducer,
Expand Down
8 changes: 5 additions & 3 deletions modules/store/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export {
SelectorWithProps,
RuntimeChecks,
FunctionWithParametersType,
EnvironmentProviders,
} from './models';
export { createAction, props, union } from './action_creator';
export { createActionGroup, emptyProps } from './action_group_creator';
Expand Down Expand Up @@ -52,13 +53,14 @@ export {
USER_PROVIDED_META_REDUCERS,
USER_RUNTIME_CHECKS,
ACTIVE_RUNTIME_CHECKS,
FEATURE_STATE_PROVIDER,
ROOT_STORE_PROVIDER,
} from './tokens';
export {
StoreModule,
StoreRootModule,
StoreFeatureModule,
RootStoreConfig,
StoreConfig,
FeatureSlice,
} from './store_module';
export { RootStoreConfig, StoreConfig, FeatureSlice } from './store_config';
export { provideStore, provideState } from './provide_store';
export { ReducerTypes, on, createReducer } from './reducer_creator';
8 changes: 8 additions & 0 deletions modules/store/src/models.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ImportedNgModuleProviders } from '@angular/core';

export interface Action {
type: string;
}
Expand Down Expand Up @@ -173,3 +175,9 @@ export interface RuntimeChecks {
*/
strictActionTypeUniqueness?: boolean;
}

/** An alias type of ImportedNgModuleProviders
* that better describes where the providers
* are allowed to be registered.
*/
export type EnvironmentProviders = ImportedNgModuleProviders;
Loading

0 comments on commit 5639c1e

Please sign in to comment.