Coder Social home page Coder Social logo

js-sdk's People

Contributors

dependabot[bot] avatar instanceofma avatar mahmedbutt avatar moizhusnain avatar oyesameed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

js-sdk's Issues

Data units in all related responses are now shifted to Bytes.

Data units in responses of routes like listAllFiles, listAllCollections are now shifted to 'Bytes'. In their responses, keys like totalSize will now be a NUMBER (1024), instead of STRING (1024 Bytes OR 1 KB) which it was previously.
For doing its formatting on the front end, you can define this function in the SDK:

pretty(number) {
   // Converts a number to proper data size units
   const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
   if (number === 0) {
       return '0 Bytes';
   }
   else {
       const i = Math.floor(Math.log(number) / Math.log(1024));
       return parseFloat((number / Math.pow(1024, i)).toFixed(2)) + ' ' + sizes[i];
   }
}

Flush subscriptions on logout

When we logout with SDK, the project object never really gets destroyed. It can be reused again, particularly in case of browsers. This is where we are encountering an error with subscriptions.

Senario

Developer subscribed to a topic (as a part of app logic). Then logged out and logged back in. The app logic will kick in again and we will try to subscribe to the topic again. The callback will getting stacked, but SDK isn't sending sub packet to server.

This is happening because the project object was reused. We were already subscribed to the topic, the older callback was stacked and as per the logic of SDK, we don't send another sub packet to server if it was subscribed before (we just stack the second callback and relay event to both callbacks whenever we get an update). But now in our case, because of the logout, the topic was automatically unsubscribed on server. But to SDK, the topic was subscribed (since there is already a callback on the topic).

This issue can be easily fixed by simply flushing the event handlers on logout event (when connection gets closed).

Send ping with exponential delay

To prevent resource consumption, we should send ping with exponential delay. And only send ping when you will receive the response of last ping request. We are talking about ping to connect to the server.

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.