如何在角度中使用Hyperledger作曲家事件订阅者

时间:2018-05-09 08:13:11

标签: node.js angular hyperledger-composer

这是eventSubscrbie js文件。

'use strict';



const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection;



class SubscribeEvent{


        constructor() {


                this.NetworkConnection = new BusinessNetworkConnection();

                this.CONNECTION_PROFILE_NAME = "admin@resumenetwork";

        }

        init() {



                return this.NetworkConnection.connect(this.CONNECTION_PROFILE_NAME)

                .then((result) => {

                        this.businessNetworkDefinition = result;

                        //LOG.info(this.businessNetworkDefinition.getIdentifier());

                })

                // and catch any exceptions that are triggered

                .catch(function (error) {

                        throw error;

                });



        }


        /** Listen for the sale transaction events

        */

        listen(){

                this.NetworkConnection.on('event',(getEvent)=>{


                        var temp = JSON.stringify(getEvent['txForUser']);

                        var evt = JSON.parse(temp);

                        console.log(evt['certificateName']);

                        console.log(evt['certificateScore']);

                        console.log(evt['organizationId']);

                        console.log(evt['organizationName']);

                        console.log(evt['dob']);

                        console.log(evt['expirationDate']);

                        console.log(evt['isPublic']);

                        console.log(evt['userId']);

                        console.log(evt['timestamp']);

       });

     }


}



module.exports = SubscribeEvent;

我想使用angular4组件中的代码。

所以我插入了一个BusinessNetworkConnection模块。

在组件ts文件中,

import { BusinessNetworkConnection  } from 'composer-client';


export class test {
   var businessnetworkconnection = BusinessNetworkConnection();

}

结果是警告信息

  警告在./~/composer-common/lib/connectionprofilemanager.js   132:57-69关键依赖:依赖的请求是一个   表达

     警告在./~/composer-common/lib/log/logger.js 422:27-35严重   依赖:依赖的请求是表达式

     警告在./~/composer-common/lib/log/logger.js 618:23-39严重   依赖:依赖的请求是表达式

     警告在./~/composer-common/lib/config/configmediator.js 44:27-35   关键依赖:依赖的请求是表达式

     警告在./~/composer-common/lib/module/loadModule.js 71:25-43   关键依赖:依赖的请求是表达式

在我的角网页上显示了相同的警告信息

已经安装了所有依赖模块。

1 个答案:

答案 0 :(得分:0)

你可以忽略它们。这只是警告关于作为表达式编写的依赖(正如它所提到的)。如果您不想在Angular中看到警告消息,网上有一些解决方案。