Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signal store demo #219

Merged
merged 20 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
304ee1b
Revert "feat(signal-store): signal store: remove demo code"
mini-rx Jul 14, 2023
b6625eb
Merge branch 'signal-store' into signal-store-demos
mini-rx Nov 24, 2023
8154910
feat(signal-store-angular-demo): signal-store-angular-demo
mini-rx Nov 24, 2023
a73bdee
feat(signal-store-angular-demo): signal-store-angular-demo
mini-rx Nov 24, 2023
7cb1125
Merge branch 'signal-store' into signal-store-demos
mini-rx Dec 1, 2023
64bf66b
feat(signal-store-angular-demo-standalone): add modern angular demo
mini-rx Dec 1, 2023
da1e911
feat(signal-store-angular-demo-standalone): add modern angular demo
mini-rx Dec 6, 2023
4644033
feat(signal-store-angular-demo-standalone): easier routing
mini-rx Dec 7, 2023
527c4d4
feat(signal-store-angular-demo): remove module based demo
mini-rx Apr 26, 2024
5f14e9c
feat(signal-store-angular-demo): cleanup
mini-rx Apr 26, 2024
2e7ff2c
feat(signal-store-angular-demo): cleanup
mini-rx Apr 26, 2024
39b5f4e
feat(signal-store-angular-demo-standalone): cleanup
mini-rx Apr 26, 2024
c1a89b7
feat(signal-store-angular-demo-standalone): comment
mini-rx Apr 29, 2024
2f15633
feat(signal-store-angular-demo-standalone): user facade service
mini-rx Apr 29, 2024
9107e07
feat(signal-store-angular-demo-standalone): build script
spierala Apr 29, 2024
5b466ac
Merge remote-tracking branch 'origin/master' into signal-store-demos
mini-rx Apr 30, 2024
62c88ff
feat(signal-store-angular-demo-standalone): cleanup
mini-rx Apr 30, 2024
cab14c0
feat(signal-store-angular-demo-standalone): update yarn lock
mini-rx Apr 30, 2024
6c02e6c
feat(signal-store-angular-demo-standalone): fixes from PR
mini-rx Jul 15, 2024
302b36d
feat(signal-store-angular-demo-standalone): fixes from PR
mini-rx Jul 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
spierala marked this conversation as resolved.
Show resolved Hide resolved
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
Loading