iotaledger / curl.lib.js

IOTA Proof-of-Work algorithm ported to Javascript to work in WebGL2-enabled browsers
GNU General Public License v3.0
37 stars 31 forks source link

added setOnProgress #24

Open peterwilli opened 6 years ago

peterwilli commented 6 years ago

When using the overrided addToTangle, you can link yourself to this event to show the user some realtime progress. This is especially handy (ba dum tss) when you PoW multiple bundles at the same time.

Behaviour shouldn't change with this PR, but it's like 04:30 in the night over here so merge with caution :+1:

Example:

curl.setOnProgress((i) => {
    this.powProgress = Math.min((i / parseFloat(preparedTransfers.length)), 1)
})
laubsauger commented 6 years ago

Looks simple enough. Should probably ensure that the passed parameter is of type "function" though.

peterwilli commented 6 years ago

@laubsauger you're right, it seems to be a standard practice throughout the library. I'll add it.