DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
  • Infrastructure
    • can-construct
      • prototype
        • constructor
        • init
        • setup
      • static
        • constructorExtends
        • extend
        • newInstance
        • setup
        • shortName
    • can-control
    • can-event
    • can-event/async/async
    • can-event/batch/batch
    • can-observation
    • can-simple-map
    • can-util
    • can-view-callbacks
    • can-view-live
    • can-view-model
    • can-view-nodelist
    • can-view-parser
    • can-view-scope
    • can-view-target
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Infrastructure
  • /
  • can-construct
  • /
  • setup
  • / On this page
    • setup

      function

      Perform initialization logic for a constructor function.

      • source

      Construct.setup(base, fullName, staticProps, protoProps)

      A static setup method provides inheritable setup functionality for a Constructor function. The following example creates a Group constructor function. Any constructor functions that inherit from Group will be added to Group.childGroups.

      Group = Construct.extend({
        setup: function(Construct, fullName, staticProps, protoProps){
          this.childGroups = [];
          if(Construct !== Construct){
            this.childGroups.push(Construct)
          }
          Construct.setup.apply(this, arguments)
        }
      },{})
      var Flock = Group.extend(...)
      Group.childGroups[0] //-> Flock
      

      Parameters

      1. base {constructor}:

        The base constructor that is being inherited from.

      2. fullName {String}:

        The name of the new constructor.

      3. staticProps {Object}:

        The static properties of the new constructor.

      4. protoProps {Object}:

        The prototype properties of the new constructor.

      The static setup method is called immediately after a constructor function is created and set to inherit from its base constructor. It is useful for setting up additional inheritance work. Do not confuse this with the prototype setup method.

      Example

      This Parent class adds a reference to its base class to itself, and so do all the classes that inherit from it.

      Parent = Construct.extend({
        setup : function(base, fullName, staticProps, protoProps){
          this.base = base;
      
          // call base functionality
          Construct.setup.apply(this, arguments)
        }
      },{});
      
      Parent.base; // Construct
      
      Child = Parent({});
      
      Child.base; // Parent
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.