trufflesuite / drizzle

Reactive Ethereum dapp UI suite
906 stars 238 forks source link

this.$drizzleEvents.$on("drizzle/contractEvent" seems not to work #54

Closed adamskrodzki closed 4 years ago

adamskrodzki commented 4 years ago

Hi,

I used vue-drizzle truffle box and added to App.vue

    mounted: function() {
     // eslint-disable-next-line
    console.log("mounting works");

    this.$drizzleEvents.$on("drizzle/contractEvent", payload => {
             // eslint-disable-next-line
             console.log("event catched", payload);

    });

  }

but despite using transfer form (and seing balance changed) I see no "event catched" text in browser console

jimpeebles commented 4 years ago

Hey @adamskrodzki ,

Assuming you are using this box.

There's only one event that's set up by default, StorageSet on the SimpleStorage contract. You can open drizzleOptions.js and see where you can specify events for Drizzle to listen for. So the Simple Storage field is the only one that should generate an event when changing the value. Is that the one you're trying?

Your code worked for me - I installed the latest version of Truffle, unboxed it, and pasted your code into App.vue - message showed up in the console as expected.

adamskrodzki commented 4 years ago

thank You for guideline from docs it was not clear to me that I need to specify in drizzleOptions.js what events is app liestening to. I was testing on TutorialToken transer. Now it is all working. Thanks a lot.

cds-amal commented 4 years ago

@adamskrodzki I'll close this issue now! Thanks @jimpeebles !

jimpeebles commented 4 years ago

Thanks @cds-amal ! And thanks for the helpful feedback @adamskrodzki , glad everything is working for you now. I've made a PR to make that portion of the readme clearer for other users.