Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

arale-base

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arale-base

Base 是一个基础类,提供 Class、Events、Attribute 和 Aspect 支持。

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Base


spm package Build Status Coverage Status

Base 是一个基础类,提供 ClassEvents、Attribute 和 Aspect 支持。


使用说明

extend Base.extend(properties)

基于 Base 创建子类。例子:

/* pig.js */
define(function(require, exports, module) {
    var Base = require('base');

    var Pig = Base.extend({
        attrs: {
            name: ''
        },
        talk: function() {
            alert('我是' + this.get('name'));
        }
    });

    module.exports = Pig;
});

继承 Base 可覆盖 initialize 构造函数, 但需要调用父类构造函数,如 arale 的 widget 定义了组件的生命周期

/* widget.js */
define(function(require, exports, module) {
    var Base = require('base');

    var Widget = Base.extend({
        initialize: function(config) {
            Widget.superclass.initialize.call(this, config);
            this.parseElement()
            this.initProps()
            this.delegateEvents()
            this.setup()
        },
        ...
    });

    module.exports = Widget;
});

Base 继承和混入了一下功能,可查看文档 :

Base 与 Class 的关系

Base 是使用 Class 创建的一个基础类,默认混入了 EventsAttributeAspect 模块:

/* base.js */
define(function(require) {

    var Class = require('class');
    var Events = require('events');
    var Aspect = require('./aspect');
    var Attribute = require('./attribute');

    var Base = Class.create({
        Implements: [Events, Aspect, Attribute],

        initialize: function(config) {
            ...
        },

        ...
    });

    ...
});

Keywords

FAQs

Package last updated on 17 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc