dparlevliet / node.bittrex.api

Node Bittrex API is an asynchronous node.js library for the Bittrex API, the data can be received either via GET request or Stream.
MIT License
253 stars 100 forks source link

Promise support #129

Closed charly37 closed 6 years ago

charly37 commented 6 years ago

Hi,

Thx for the library and the good work. I wanted to check if it is possible to have promise instead of pushing callback function ? I check the readme and issues (in particular): https://github.com/dparlevliet/node.bittrex.api/issues/77 https://github.com/dparlevliet/node.bittrex.api/pull/7 I think it is not supported but would like confirmation. It would be nice to have that in the future. Thx

victor-stone commented 6 years ago

fwiw I rolled my own that you're welcome to try (and test ;)) https://github.com/victor-stone/bittrex-promise

xunholy commented 6 years ago

Just use bluebird, or alternatively use async await with bluebird so you don't get promise hell.

EG

` let Promise = require('bluebird') Promise.promisifyAll(bittrex)

async checkOrderCompletedAsync (marketWatch) { try { let query = { 'market': marketWatch.market } let allCompletedOrders = await bittrex.getorderhistorycustomAsync(query, marketWatch.apikey, marketWatch.apisecret) for (let completedOrder of allCompletedOrders.result) { if (marketWatch.orderUUID === completedOrder.OrderUuid) { return true } } return false } catch (error) { console.log('Error while attempting to check completed order ' + JSON.stringify(error)) throw error } }`

dparlevliet commented 6 years ago

Correct, it's not - those that need promises enable them by using bluebird or similar. There is a setting to invert the response param order to accommodate.

charly37 commented 6 years ago

Thx guys for the info. Will try to to enable them with external libs (and maybe play with await async).