Comments (7)
Hi, I'm not using TS on my apps so I haven't encountered this issue, would setting path as optional work :
public subscribe (path?: string, callback: (data: any) => void, triggerNow?: boolean) {
?
Another option would be to set path type as string | null
and then when subscribing to the complete record you pass null
as path (that works currently)
from deepstream.io-client-js.
Hi,
I'd personally go with the second solution. However, that would be a breaking change.
Setting the path to optional won't work because a required parameter cannot follow an optional parameter.
So the question remains, is it ok to introduce a breaking change to the client? 😊
(I mean to introduce a breaking change to the non-TS usage of the client as well.
Currently, it is not consistent and I think it should be.)
If yes, I'll create a PR.
from deepstream.io-client-js.
Let me recap and see if we are talking about the same:
- The TS compiler throws error when you do
record.subscribe(callback)
due to typing issues, it requires a defined path with a string value (I haven't veryfied this, but seems legit from the source) - In the current client you can subscribe to the complete record by doing
record.subscribe(callback)
orrecord.subscribe(null, callback)
: both options work
Possible solutions:
-
Set the path type to
string | null
and thus TS users would have to call the function asrecord.subscribe(null, callback)
for subscribing to the complete record and wouldn't have type problems from the TS compiler. As far as I see this won't be a breaking change for JS users, although a nasty difference between TS and JS usage. -
Follow my linter suggestion :) Set the
record.subscribe
function parameters as unused by prefixing an underscore:_path, _callback, _triggerNow
: could you check if this solves your issue?
from deepstream.io-client-js.
Yes, it seems that we are on the same page. Thanks for the clarification.
Prefixing the params doesn't solve the issue.
I'd go with setting the path type to string | null
I was talking about a breaking change because my initial thought was not to allow different usages for TS and JS users.
However, if you say that we can live with the non-consistent calls, then I would recommend updating the docs to promote the record.subscribe(null, callback)
usage for everyone from now on.
from deepstream.io-client-js.
Another option, take a look at the same record.ts
source here for example : multiple definitions are used in order to cover all possible cases. Maybe that's the rigth way to go. Hope you have a chance to test it, that would be the ideal scenario, no changes needed to documentation or anything else.
from deepstream.io-client-js.
Great suggestion. 👍 Works like a charm. PR sent.
from deepstream.io-client-js.
Excelent
from deepstream.io-client-js.
Related Issues (20)
- dist directory/.js-file for browser is missing HOT 12
- Deepstream-client have not worked in ReactNative HOT 3
- C and Options are not exported from dist/bundle/ds.min.js HOT 1
- Problem of usage in nodejs 14.5 with the lastest version of @deepstream/[email protected] HOT 10
- client.presence.subscribe('username', callback) not working HOT 1
- ACCEPT_TIMEOUT weired behavior HOT 4
- getting error referrence error HOT 1
- Issue an event to a user by their ID HOT 1
- In chrome, new DeepstreamClient, then the XmlHttpRequest won't work. HOT 1
- How can I make data timeout auto clear? HOT 1
- DeepstreamClient - RPC ResponseTimeout HOT 1
- Uncaught ReferenceError: Buffer is not defined HOT 6
- NextJS 13 - PNPM - bufferuntil HOT 2
- Deprecate old SDK HOT 2
- Doesn't works with React Native (Expo) With Hermes HOT 7
- Discard list still get event handler triggered HOT 1
- Record subscription after reconnect HOT 9
- Cannot use deepstream-client-js in React Native app android HOT 4
- TypeError: require_ws(...) is not a constructor HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deepstream.io-client-js.