How to use Hyperledger composer event subscriber i

2019-06-14 14:00发布

this is eventSubscrbie js File.

'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;

I want to use the code in angular4 component.

so I insert a BusinessNetworkConnection module.

In component ts file,

import { BusinessNetworkConnection  } from 'composer-client';


export class test {
   var businessnetworkconnection = BusinessNetworkConnection();

}

as a result, warning message

WARNING in ./~/composer-common/lib/connectionprofilemanager.js 132:57-69 Critical dependency: the request of a dependency is an expression

WARNING in ./~/composer-common/lib/log/logger.js 422:27-35 Critical dependency: the request of a dependency is an expression

WARNING in ./~/composer-common/lib/log/logger.js 618:23-39 Critical dependency: the request of a dependency is an expression

WARNING in ./~/composer-common/lib/config/configmediator.js 44:27-35 Critical dependency: the request of a dependency is an expression

WARNING in ./~/composer-common/lib/module/loadModule.js 71:25-43 Critical dependency: the request of a dependency is an expression

and same warning message was displayed at my angular web page

all dependency module is already installed.

1条回答
beautiful°
2楼-- · 2019-06-14 14:13

you can ignore them. This is simply warning about a dependency written as an expression (as it mentions). There are some solutions on the web if you don't want to see the warning messages in Angular.

查看更多
登录 后发表回答