Giter Site home page Giter Site logo

changedetection's Introduction

ChangeDetection

This project was generated with Angular CLI version 15.2.1.

App Purpose

I created this app to understand the change detection strategy onPush to enhance performance of one of projects that I am working on.

Setting Change Detection to OnPush will prevent all input reference variable updates to trigger change detection.

I tried this with an array and push new value to it, so when set change detection to onpush there is no updates cuz the reference didn't change to the array.

when make the same with primitive type it feels the change even if the change detection strategy to onpush cuz the reference to the value changed that is becuse of the immutability.

OnPush works with mutable data types.

Immutable data types are those which return a new reference to the variable when their values are updated. For example, when the count variable is updated from 3 to 4, the variable returned a new reference to the input parameter. Hence the change detection was triggered.

Mutable variables are those which can be updated without returning a new reference. For example arrays, objects, etc. So when we did

ChangeDetectionStrategy.OnPush prevents Angular’s check to move up to the parent if there is no new reference.

Now what if we want some of the arrays to be checked for change detection even if the component has OnPush 1- this.unImportantItems = […this.unImportantItems,’Batgirl’];

Custom Validation for the template driven form

custom validations for the template-driven form. Checking for user name availability Password pattern validation Matching the password entered in two different fields

1-create CustomvalidationService 2-Create the User model 3-Create custom directives

take the first page of file uploaded as a screenshot

in

Development server

Run ng serve for a dev server. Navigate to http://localhost:4200/. The application will automatically reload if you change any of the source files.

Code scaffolding

Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.

Build

Run ng build to build the project. The build artifacts will be stored in the dist/ directory.

Running unit tests

Run ng test to execute the unit tests via Karma.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.

changedetection's People

Contributors

yasminkasem avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.