grandeurdev / js-sdk Goto Github PK
View Code? Open in Web Editor NEWGrandeur client for browsers
Home Page: https://docs.grandeur.dev
License: MIT License
Grandeur client for browsers
Home Page: https://docs.grandeur.dev
License: MIT License
Currently the link under "About" section is directing to https://docs.grandeur.tech
Whereas it should have directed to https://docs.grandeur.dev
Why are we doing this?
js-sdk/src/handlers/duplex.handler.js
Line 283 in edb75c3
When we call unsub from one callback, it removed the subscription entirely, rendering other callbacks useless.
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];
}
}
Adding typescript support to react sdk and browser sdk.
js-sdk/src/handlers/duplex.handler.js
Line 228 in 61db45f
Our server also provides res.error functionality, ideally we should reject promise when server marks the response as error, but we aren't using this functionality. (https://github.com/grandeurdev/backend/blob/bf3429441b84326b80b34e4977a653fde2e602a8/routes/duplex/projects.js#L28)
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).
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.
When we aren't specifying name of the file and do file upload, the response comes out as invalid signature.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.