GithubHelp home page GithubHelp logo

angular-apply-async-readme-web-0217's Introduction

$applyAsync in $http

Overview

$applyAsync is a small performance offering from Angular - only really affecting apps with lots of $http calls. Either way, it speeds things up!

Objectives

  • Describe $applyAsync in $http
  • Use $applyAsync in config()

applyAsync

We can turn on $applyAsync in our modules config.

angular
	.module('app')
	.config(function ($httpProvider) {
        $httpProvider.useApplyAsync(true);
	});

Here we're injecting $httpProvider (that configures everything to do with $http) and turning applyAsync on. But what does it actually do?

applyAsync batches our $http calls that happen at a similar time into one digest cycle call. If we have two $http calls that happen at the same time, normally we'd be running two digest cycles - this isn't great for performance.

Instead, applyAsync will notice that these two requests are near each other and wait for them both to complete, running one digest cycle after that. This is great! It saves a lot of processing time for one little configuration object. However, this does mean there is a slight delay between making your request and then Angular making the actual HTTP request - this is because it needs to wait to see if there are any other $http calls to batch into one.

Improving performance is all about trade offs. As you build more Angular applications, you'll become comfortable deciding when to implement this feature.

angular-apply-async-readme-web-0217's People

Contributors

ipc103 avatar toddmotto avatar

Watchers

 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.