bearcat api

createApp

The createApp is the core of bearcat. It is a factory constructor function that allows you to create bearcat instance.

start bearcat app

stop bearcat app, it will stop internal applicationContext, destroy all singletonBeans

use

add async loading beans, this just add beans needed to be loaded to bearcat.

examples:

1
2
bearcat.use(['car']);
bearcat.use('car');

async

async loading beans

examples:

1
2
3
bearcat.async(['car'], function(car) {
// car is ready
});

module

register module(bean) to IoC container through $ based self-described function.

examples:

1
2
3
4
bearcat.module(function() {
this.$id = "car";
this.$scope = "prototype";
});

getBean

get bean from IoC container through beanName or meta argument.

examples:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// through beanName
var car = bearcat.getBean("car");
// through meta
var car = bearcat.getBean({
id: "car",
func: Car // Car is a function constructor
});
// through $ annotation func
var car = bearcat.getBean(function() {
this.$id = "car";
this.$scope = "prototype";
});
1
2
3
// express
var app = express();
app.get('/', bearcat.getRoute('bearController', 'index'));
1
2
// through beanName
var Car = bearcat.getFunction("car");
1
2
// through modelId
var carModel = bearcat.getModel("car");
1
2
3
4
bearcat.getBeanByFunc(function() {
this.$id = "car";
this.$scope = "prototype";
});
1
2
3
4
bearcat.getBeanByMeta({
id: "car",
func: Car // Car is a function constructor
});