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

IIFE: Wrap #83

Open
kocur4d opened this issue Oct 17, 2015 · 1 comment
Open

IIFE: Wrap #83

kocur4d opened this issue Oct 17, 2015 · 1 comment

Comments

@kocur4d
Copy link

kocur4d commented Oct 17, 2015

IIFE: Wrap AngularJS components in an Immediately Invoked Function Expression (IIFE).

CoffeeScript automatically wraps every file in to IIFE, this suggestion is not necessary while working with coffeescript

campaign_service.js.coffee

CampaignService = ->
  {}

angular
  .module 'dashboard'
  .factory 'CampaignService', [
    CampaignService
  ]

Will become:

campaign_service.js

(function() {
  var CampaignService;

  CampaignService = function() {
    return {};
  };

  angular.module('dashboard').factory('CampaignService', [CampaignService]);

}).call(this);
@Hettomei
Copy link

Hettomei commented Mar 1, 2017

I was trying the same thing :

$ coffee --version
CoffeeScript version 1.12.2
#test.coffee
a = 4
console.log(a+4);

coffee -c -o . test.coffee ->

// Generated by CoffeeScript 1.12.2
(function() {
  var a;

  a = 4;

  console.log(a + 4);

}).call(this);

Can we remove this part from readme ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants