Topics

答复: [Hyperledger Fabric] How to send fabric chaincode events received in node.js application to angular application? #fabric-sdk-node

david liu
 

That is a general nodejs function, not specific for fabric. But AFAIK, you could use outside function and variable inside callback with `closure` pattern or even directly using the context scope.

 

Best Regards,

David Liu

+852 5982 3942

 


发件人: fabric@... <fabric@...> 代表 Prasanth Sundaravelu <prasanths96@...>
发送时间: Thursday, January 17, 2019 9:04:32 PM
收件人: fabric@...
主题: [Hyperledger Fabric] How to send fabric chaincode events received in node.js application to angular application? #fabric-sdk-node
 

Hi guys,
I'm using registerChaincodeEvent(ccid, eventCallBack, errorCallBack, options) to listen to events from my blockchain. The problem with this is that the eventCallBack function is not able to access variables or functions outside it. So, how could we pass the event received outside this callback function? I need to use the received event in server sent event (sse) which I have in another node.js application.

Thanks in advance.

Prasanth Sundaravelu
 

Thanks for reply. 

I have tried passing in an outside function as a parameter for registerChaincodeEvent 
now it does not recognize it as eventCallback function and throws error like "eventCallback parameter not passed".


P.S.: Sorry for posting this question here, but I thought someone who might have already solved this specific scenerio could help.