Bonnes Pratiques Web & Cloud
58.8K views | +4 today
Follow
Bonnes Pratiques Web & Cloud
Administration cloud et développement web
Curated by Mickael Ruau
Your new post is loading...
Your new post is loading...

Popular Tags

Current selected tag: 'AngularJS - framework Javascript MVW'. Clear
Scooped by Mickael Ruau
Scoop.it!

Three things you didn't know about the AsyncPipe

Three things you didn't know about the AsyncPipe | Bonnes Pratiques Web & Cloud | Scoop.it

You sure heard about Angular’s AsyncPipe haven’t you? It’s this handy little pipe that we can use from within our templates so that we don’t have to deal with unwrapping data from Observables or Promises imperatively. Turns out the AsyncPipe is full of little wonders that may not be obvious at first sight. In this article we like to shed some light on the inner workings of this useful little tool.

No comment yet.
Scooped by Mickael Ruau
Scoop.it!

Easy Reactive Forms in Angular Using Formly

Easy Reactive Forms in Angular Using Formly | Bonnes Pratiques Web & Cloud | Scoop.it
Formly is a package that let's us create reactive forms in Angular with a simple JSON object. Let's see how it can be used.
No comment yet.
Scooped by Mickael Ruau
Scoop.it!

AngularJS Performance in Large Applications

AngularJS Performance in Large Applications | Bonnes Pratiques Web & Cloud | Scoop.it

##12 Summary

###12.1 AngularJS: The bad parts

  • ng-click and other DOM events
  • scope.$watch
  • scope.$on
  • Directive postLink
  • ng-repeat
  • ng-show and ng-hide

###12.2 AngularJS: The good (performant) parts

  • track by
  • oneTime bindings with ::
  • compile and preLink
  • $evalAsync
  • Services, scope inheritance, passing objects by reference
  • $destroy
  • unbinding watches and event listeners
  • ng-if and ng-switch
Mickael Ruau's insight:

Tools of the Trade

2.1 Benchmarking

A fantastic tool for benchmarking one's code is jsPerf. I will link to specific test runs at the end of relevant sections for readability.

2.2 Profiling

The Chrome Dev Tools have a fantastic Javascript profiler. I highly recommend reading this series of articles.

2.3 Angular Batarang

A dedicated Angular debugger is maintained by the Angular Core Team and available on GitHub.

No comment yet.
Scooped by Mickael Ruau
Scoop.it!

Créer rapidement un système d'authentification

Créer rapidement un système d'authentification | Bonnes Pratiques Web & Cloud | Scoop.it
Ce tutoriel se charge de vous apprendre à créer rapidement un système d'authentification à partie d' Angular et de Symfony3.
No comment yet.
Scooped by Mickael Ruau
Scoop.it!

7 Angular Tools That You Should Consider · Minko Gechev's blog

7 Angular Tools That You Should Consider · Minko Gechev's blog | Bonnes Pratiques Web & Cloud | Scoop.it

In this article we explore a couple of tools which can improve our development experience dramatically! Starting from project scaffolding with the Angular CLI, going through efficient development with the Angular Language Service and Angular Snippets, to dynamic and static code analysis for easy debugging and reverse engineering!

 

Mickael Ruau's insight:

Have you ever worked on an application where you had to automatically generate the API documentation? For JavaScript we have tools like ESDoc which take the JSDoc annotations and automatically generate documentation for us. The end result usually looks something like this.

This is enough for most projects but Angular provides some extra semantics on top that can make our documentation even richer! For instance, it allows us to list all the different UI components just by grabbing all classes decorated with @Component. Well, compodoc already does this for us!

 

(...)

John Papa created a package of snippets for VSCode which improves our productivity by reducing the amount of boilerplate work that we need to perform when:

  • Bootstrapping an Angular application.
  • Declaring a new component.
  • Declaring guards.
  • Declaring directive.
  • Declaring a route.
  • Declaring a service.
  • etc.

You can take advantage of the snippets by installing the VSCode extension available here.

No comment yet.
Scooped by Mickael Ruau
Scoop.it!

AngularJS : comment utiliser scope.$watch et scope.$apply ?

AngularJS : comment utiliser scope.$watch et scope.$apply ? | Bonnes Pratiques Web & Cloud | Scoop.it

Le framework AngularJS possède un cycle appelé cycle $digest. Ce cycle est constitué de 2 boucles, $evalSync et $watch, qui évaluent les changements effectués sur le modèle. Tant que la boucle $evalSync n'est pas vide, elle se répète, et le framework met à jour le DOM en fonction de ces modifications. Une fois la boucle vide, le framework affiche le DOM mis à jour.

La variable scope.$watch permet de marquer des variables pour qu'elles soient surveillées par le framework. Une variable marquée sera analysée par le framework à chaque itération de la boucle. C'est l'une des deux manières d'indiquer au framework de monitorer une variable (l'autre étant de la déclarer dans un template avec cette expression : {}).

Mickael Ruau's insight:

$apply permet de lancer manuellement le cycle $digest. Si vous modifiez une variable directement dans le scope, vous n'avez pas besoin de faire appel à cette méthode. AgularJS va directement détecter le changement, car il est programmé pour le faire. Si vous changez une variable en dehors du framework, ce ne sera pas le cas. Par exemple, un changement fait dans une requête Ajax avec JQuery ne sera pas détecté par le framework. C'est à ce moment qu'il faut utiliser $apply. $apply lance le cycle $digest du framework, et permet ainsi l'intégration des modifications faites par des méthodes non gérées par le framework.

No comment yet.
Scooped by Mickael Ruau
Scoop.it!

3 Types of Route Loading in Angular, Explained In 500ish words

…so this post sets out to explain the concepts of each type of loading in simple language.

No comment yet.
Scooped by Mickael Ruau
Scoop.it!

Tiny JS frameworks: Preact and Svelte – Chris Davies – Medium

This week, I found out about Svelte, a teensy front-end UI framework. I’m a fan of Preact, and I wondered how big a real application with Svelte would be compared to Preact.

Short answer: a simple CRU (no D) app for creating, listing, updating a users list, complete with client-side routing using rlite-router and JS-manipulated CSS weighs in at:

  • Preact 6.2KB (min + gzip)
  • Svelte 4.8KB (min + gzip)

Without JS-based styling (e.g. with external CSS), the Svelte app came in at exactly 4KB.

Pretty sweet. That’s an entire application with front-end routing, in a much smaller than react-router alone.

No comment yet.
Scooped by Mickael Ruau
Scoop.it!

Opinionated AngularJS styleguide for teams

Opinionated AngularJS styleguide for teams | Bonnes Pratiques Web & Cloud | Scoop.it

After reading Google’s AngularJS guidelines, I felt they were a little too incomplete and also guided towards using the Closure library. They also state “We don’t think this makes sense for all projects that use AngularJS, and we’d love to see our community of developers come up with a more general Style that’s applicable to AngularJS projects large and small”, so here goes.

No comment yet.
Scooped by Mickael Ruau
Scoop.it!

MVC, MVVM and Angular

MVC, MVVM and Angular | Bonnes Pratiques Web & Cloud | Scoop.it

AngularJS is one of the most popular front-end JavaScript frameworks. It is used to create dynamic, interactive and responsive web applications. It is a full-featured Single Page Application (SPA) framework.

Angular supports the principles behind the Model-View-Controller (MVC) design pattern. In this post, let us examine the concepts behind MVC and MVVM; also try to map Angular constructs to the MVVM pattern.

Mickael Ruau's insight:

View Model

The view model acts as an intermediary between the view and the model, and is responsible for handling the view logic. Typically, the view model interacts with the model by invoking methods in the model classes. The view model then provides data from the model in a form that the view can easily use. The view model retrieves data from the model and then makes the data available to the view, and may reformat the data in some way that makes it simpler for the view to handle. The view model also provides implementations of commands that a user of the application initiates in the view. For example, when a user clicks a button in the UI, that action can trigger a command in the view model.

Implementing MVVM in Angular

Angular supports the principles behind MVVM design pattern in the following approach.

  • Model — The model is implemented as an Angular service (Factory or Service).
  • View — The View is implemented using Angular ‘template’ (HTML with data bindings) that is rendered into the Angular view directive (ng-view / ui-view). The View is bound to the ViewModel so that when a property is changed in the ViewModel, it is instantly reflected in the View. Data bindings can work both ways in special cases like HTML forms, where a user can manipulate a property directly.
  • ViewModel — The ViewModel is implemented as an Angular controller. The ‘ngController’ directive is used to specify a controller for a view. It can expose properties and methods to the view. It can also be attached to the DOM by declaring it in a route definition via the ‘$route’ service.

The above implementation suggestions are applicable to Angular 1.x framework.

No comment yet.
Scooped by Mickael Ruau
Scoop.it!

Un modèle d’architecture AngularJS

Un modèle d’architecture AngularJS | Bonnes Pratiques Web & Cloud | Scoop.it
Comment mettre en place une architecture basée sur le MVVM (Model View ViewModel) à l’instar du MVC (Model View Controler) qui est plus souvent utilisé ?
Mickael Ruau's insight:

« Le Modèle-Vue-VueModèle (en abrégé MVVM, de l’anglais Model View ViewModel) est une architecture et une méthode de conception utilisée dans le génie logiciel. MVVM est originaire de Microsoft et adapté pour le développement des applications basées sur les technologies Windows Presentation Foundation et Silverlight via l’outil MVVM Light par exemple. Cette méthode permet, tel le modèle MVC (Modèle-Vue-Contrôleur), de séparer la vue de la logique et de l’accès aux données en accentuant les principes de binding et d’événement. » (source)

Pour vulgariser, la différence entre MVVM et MVC tient du fait que le MVVM, lui, se repose sur le DataBading et l’évènementiel.  Ça tombe bien, c’est ce qu’AngularJS est !

 

La vue est couplée aux données via du DataBinding et invoque les méthodes du ViewModel.

Le ViewModel invoque les méthodes du modèle. Il contient la data spécifique à la gestion de l’écran et les méthodes de réponses aux interactions utilisateurs. Il contient également une référence vers un ou des modèles.

Le modèle contient la data et les méthodes de manipulation de cette dernière (calculs, appels de services, …).

No comment yet.