Skip to content

Run Blocks (Y171) #53

@EmmanuelDemey

Description

@EmmanuelDemey
  • Any code that needs to run when an application starts should be declared in a factory, exposed via a function, and injected into the run block.

    Why?: Code directly in a run block can be difficult to test. Placing in a factory makes it easier to abstract and mock.

    angular
        .module('app')
        .run(runBlock);
    
      runBlock.$inject = ['authenticator', 'translator'];
    
      function runBlock(authenticator, translator) {
          authenticator.initialize();
          translator.initialize();
      }

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions