-
-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JavaScript examples don't work for me #43
Comments
Hey @retendo ! Thanks for persisting long enough to make it work. // related to node/browser difference? You nailed it. The example at the the top is for "browser" JS and the one at the bottom is for "server" JS. As a short (not entirely accurate) history of JS: at the start Javascript was only really used to do little things in the browser (little animations). Then people started building whole websites with it. Then google thought.. perhaps we can run this JS on a server too, not just in a browser? So they created a "subset" of Javascript - nodejs, and they created an "engine" which could run it called But NodeJS doesn't really have the same "dialect". (Look up CommonJS vs AMD vs UMD.) This is why tools like babel exist. They "translate" JS between the different JS dialects. Anyhow - you nailed it with the If you have a nice simple example working, perhaps you could even add it as a |
I think the more important change should be the ".channel" in between join() and on( ... ). |
I'll have to check this out. Do you have an existing repo that I can fork? If it's private no probs, I'll create a small express demo in this repo |
Got some example code right here: This works with the adjusted sample code |
in addition to that wildcart paths doest work on channel path. |
socket.channel('realtime:public') works, though. Just omit the last colon. |
Hey @retendo sorry for the incommunicado - I'm looking at this & building a basic nodejs example now, but probably won't finish until tomorrow morning my time. FYI: These shouldn't work
But these should
Use the "on" to listen to different "event types". Using the code in your gist: // INSERTS
socket.channel('realtime:public')
.join()
.channel
.on('INSERT', payload => {});
// UPDATES
socket.channel('realtime:public')
.join()
.channel
.on('UPDATE', payload => {});
// DELETES
socket.channel('realtime:public')
.join()
.channel
.on('DELETE', payload => {});
// ALL
socket.channel('realtime:public')
.join()
.channel
.on('*', payload => {}); Hope that helps a bit! I haven't tested your code yet but it looks great! I see exactly where you're going with it - creating a proxy (maybe for auth purposes?) |
For auth, specialized socket APIs that hide the underlying database structure and some payload modifications. |
Small example pushed for you @retendo. I used your code as a baseline so thanks for contributing
Check out the difference between my first commit and my second: d4c9ece Basically Please keep me update on your proxy - if you can keep it generic enough I'll add it to the |
That makes sense. In the original browser based example it was all chained together, so I tried to replicate it that way. But the changes in your second commit actually make it clearer. Regarding the proxy example: I’ll see what I can do. You are probably most interested in how authentication fits into the picture, right? Because the other things that I mentioned should be straightforward. |
Yeah especially in authorization. We are working on it now, so it's good to get more perspectives/approaches. Thanks for pitching in here. If you get stuck with anything else just let us know. I'll leave this to close unless you have anything remaining |
Closing now, feel free to reopen at any stage |
Update swagger documentation, swagger schema JSON file
Hey,
just wanted to let you know that there seems to be an error in the JS examples.
I'm trying to get this to work on a node.js server. (not a JS expert)
The below code block does not work for me.
what does instead work is the following:
Thanks for the great lib :)
The text was updated successfully, but these errors were encountered: