Giter Club home page Giter Club logo

Comments (4)

artdevgame avatar artdevgame commented on July 17, 2024 1

Hey @bennycode, happy new year.

I'm ok pushing to candles for now. I share your concern with the memory allocation so don't think it's something for you to implement in hindsight.

I'll close the ticket. Thanks for the feedback.

from coinbase-pro-node.

bennycode avatar bennycode commented on July 17, 2024

Hi @artdevgame, I am happy to hear that you like the project.

The current architecture allows only to get the latest candle. You can subscribe to ProductEvent.NEW_CANDLE events and keep track of all emitted candles in your own application.

Would that be doable for you?

from coinbase-pro-node.

artdevgame avatar artdevgame commented on July 17, 2024

Hey @bennycode

I'm using the demo here:
https://github.com/bennycode/coinbase-pro-node/blob/main/src/demo/rest-watch-candles.ts

Here we retrieve all candles and assign to a variable called candles:
https://github.com/bennycode/coinbase-pro-node/blob/main/src/demo/rest-watch-candles.ts#L17

At the moment, the body of the callback (https://github.com/bennycode/coinbase-pro-node/blob/main/src/demo/rest-watch-candles.ts#L13) in my version is pushing candle to the candles array because I need to keep track of the history (I'm looking for trends).

I don't like that my callback is now causing side effects, and would like to solve that somehow, like how array.map has an optional 'array' param: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

Another way I could solve it is to have the ProductEvent.NEW_CANDLE callback call client.rest.product.getCandles again, but that seems a bit wasteful.

from coinbase-pro-node.

bennycode avatar bennycode commented on July 17, 2024

@artdevgame, I see your use case now. From my point of view, pushing incoming candles to the existing candles array does not sound like a bad idea. The alternative would be to keep all fetched candles in the memory of the "coinbase-pro-node" library, or do you have another approach?

I wouldn't like to store all fetched candles in the memory of "coinbase-pro-node", because it would consume memory even in applications which don't have your use case and it would go beyond the concerns of a REST API.

In your case using an application state container, like Redux, could be a good idea to manage your candles and handle side effects. What do you think?

from coinbase-pro-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.