Blame view

common/models/promises.js 659 Bytes
3f90e3a0   Nung Poti   เรียงลำดับการทำงา...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var bluebird = require('bluebird');
var promise = new Promise(function (resolve,reject) {
    resolve('success')
})
module.exports = function(Promises) {
    Promises.Ex = function (cb) {
        promise
            .then(MyFunc1())
            .then(MyFunc2());

    };
    function MyFunc1(){
        setTimeout(function(){
            console.log('first');
            return true;
        },1000);
    }
    function MyFunc2(){
        console.log('second');
    }
    Promises.remoteMethod('Ex',{
        http:{path:'/Ex',verb:'get'},
        accepts: { arg: 'ctx', type: 'object' } ,
        returns: {arg: 'data', type: 'object', root: true}
    })
};