Skip to content

Commit

Permalink
Merge pull request #219 from spierala/signal-store-demos
Browse files Browse the repository at this point in the history
Signal store demo
  • Loading branch information
spierala authored Jul 15, 2024
2 parents ad88004 + 302b36d commit 4cbd053
Show file tree
Hide file tree
Showing 95 changed files with 6,424 additions and 3,439 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import {Injectable} from '@angular/core';
import {Todo} from '../../todos-shared/models/todo';
import {TodoFilter} from '../../todos-shared/models/todo-filter';
import {pipe} from 'rxjs';
import {mergeMap} from 'rxjs/operators';
import {v4 as uuid} from 'uuid';
import {Action, createFeatureSelector, createSelector, FeatureStore, tapResponse,} from 'mini-rx-store';
import {TodosApiService} from '../../todos-shared/services/todos-api.service';
import {cloneDeep} from "lodash-es";
import { Injectable } from '@angular/core';
import { Todo } from '../../todos-shared/models/todo';
import { TodoFilter } from '../../todos-shared/models/todo-filter';
import { pipe } from 'rxjs';
import { mergeMap } from 'rxjs/operators';
import { v4 as uuid } from 'uuid';
import {
Action,
createFeatureSelector,
createSelector,
FeatureStore,
tapResponse,
} from 'mini-rx-store';
import { TodosApiService } from '../../todos-shared/services/todos-api.service';
import { cloneDeep } from 'lodash-es';

// STATE INTERFACE
interface TodosState {
Expand All @@ -31,7 +37,9 @@ const initialState: TodosState = {
// MEMOIZED SELECTORS
const getTodosFeatureSelector = createFeatureSelector<TodosState>();
const getTodos = createSelector(getTodosFeatureSelector, (state) => state.todos);
const getSelectedTodo = createSelector(getTodosFeatureSelector, (state) => cloneDeep(state.selectedTodo));
const getSelectedTodo = createSelector(getTodosFeatureSelector, (state) =>
cloneDeep(state.selectedTodo)
);
const getFilter = createSelector(getTodosFeatureSelector, (state) => state.filter);
const getTodosFiltered = createSelector(getTodos, getFilter, (todos, filter) => {
return todos.filter((item) => {
Expand All @@ -52,8 +60,8 @@ const getVm = createSelector({
todosDone: getTodosDone,
todosNotDone: getTodosNotDone,
filter: getFilter,
selectedTodo: getSelectedTodo
})
selectedTodo: getSelectedTodo,
});

@Injectable({
providedIn: 'root',
Expand Down
10 changes: 10 additions & 0 deletions apps/signal-store-angular-demo-standalone-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": ["plugin:cypress/recommended", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from 'cypress';
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';

export default defineConfig({
e2e: nxE2EPreset(__dirname),
});
33 changes: 33 additions & 0 deletions apps/signal-store-angular-demo-standalone-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "signal-store-angular-demo-standalone-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/signal-store-angular-demo-standalone-e2e/src",
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/signal-store-angular-demo-standalone-e2e/cypress.config.ts",
"devServerTarget": "signal-store-angular-demo-standalone:serve:development",
"testingType": "e2e"
},
"configurations": {
"production": {
"devServerTarget": "signal-store-angular-demo-standalone:serve:production"
},
"ci": {
"devServerTarget": "signal-store-angular-demo-standalone:serve-static"
}
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/signal-store-angular-demo-standalone-e2e/**/*.{js,ts}"]
}
}
},
"tags": [],
"implicitDependencies": ["signal-store-angular-demo-standalone"]
}
13 changes: 13 additions & 0 deletions apps/signal-store-angular-demo-standalone-e2e/src/e2e/app.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getGreeting } from '../support/app.po';

describe('signal-store-angular-demo-standalone', () => {
beforeEach(() => cy.visit('/'));

it('should display welcome message', () => {
// Custom command example, see `../support/commands.ts` file
cy.login('my-email@something.com', 'myPassword');

// Function helper example, see `../support/app.po.ts` file
getGreeting().contains('Welcome signal-store-angular-demo-standalone');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const getGreeting = () => cy.get('h1');
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************

// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
login(email: string, password: string): void;
}
}
//
// -- This is a parent command --
Cypress.Commands.add('login', (email, password) => {
console.log('Custom command example: Login', email, password);
});
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
17 changes: 17 additions & 0 deletions apps/signal-store-angular-demo-standalone-e2e/src/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands';
16 changes: 16 additions & 0 deletions apps/signal-store-angular-demo-standalone-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../dist/out-tsc",
"allowJs": true,
"types": ["cypress", "node"],
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*.ts", "src/**/*.js", "cypress.config.ts"]
}
36 changes: 36 additions & 0 deletions apps/signal-store-angular-demo-standalone/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "miniRx",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "mini-rx",
"style": "kebab-case"
}
]
},
"extends": [
"plugin:@nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
]
},
{
"files": ["*.html"],
"extends": ["plugin:@nx/angular-template"],
"rules": {}
}
]
}
22 changes: 22 additions & 0 deletions apps/signal-store-angular-demo-standalone/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-disable */
export default {
displayName: 'signal-store-angular-demo-standalone',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
coverageDirectory: '../../coverage/apps/signal-store-angular-demo-standalone',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
],
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};
105 changes: 105 additions & 0 deletions apps/signal-store-angular-demo-standalone/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"name": "signal-store-angular-demo-standalone",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"prefix": "mini-rx",
"sourceRoot": "apps/signal-store-angular-demo-standalone/src",
"tags": [],
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:browser",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/signal-store-angular-demo-standalone",
"index": "apps/signal-store-angular-demo-standalone/src/index.html",
"main": "apps/signal-store-angular-demo-standalone/src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "apps/signal-store-angular-demo-standalone/tsconfig.app.json",
"assets": [
"apps/signal-store-angular-demo-standalone/src/favicon.ico",
"apps/signal-store-angular-demo-standalone/src/assets"
],
"styles": [
"apps/signal-store-angular-demo-standalone/src/styles.scss",
"node_modules/bootstrap/scss/bootstrap.scss",
"node_modules/ngx-toastr/toastr.css"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"executor": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "signal-store-angular-demo-standalone:build:production"
},
"development": {
"browserTarget": "signal-store-angular-demo-standalone:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "signal-store-angular-demo-standalone:build"
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"apps/signal-store-angular-demo-standalone/**/*.ts",
"apps/signal-store-angular-demo-standalone/**/*.html"
]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/signal-store-angular-demo-standalone/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"serve-static": {
"executor": "@nx/web:file-server",
"options": {
"buildTarget": "signal-store-angular-demo-standalone:build"
}
}
}
}
Loading

0 comments on commit 4cbd053

Please sign in to comment.