Comments (12)
socket.channel('realtime:public') works, though. Just omit the last colon.
from realtime.
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
from realtime.
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 v8
.
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 require('@supabase/realtime-js');
for Node
If you have a nice simple example working, perhaps you could even add it as a node-js
example in the /examples
folder? We're very open to contributors.
from realtime.
I think the more important change should be the ".channel" in between join() and on( ... ).
This seems unrelated to node.js/browser differences.
Or is this somehow working in the browser?
It seems that .join() returns a Push object instead of a Channel.
from realtime.
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
from realtime.
Got some example code right here:
https://gist.github.com/retendo/3e2ddb90a29dfd0f5a2ab81729c7ed29
This works with the adjusted sample code
from realtime.
in addition to that wildcart paths doest work on channel path.
socket.channel('realtime:public:users') -> works
socket.channel('') -> broken
socket.channel('realtime:') -> broken
socket.channel('realtime:public:*') -> broken
from realtime.
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
socket.channel('') -> broken
socket.channel('realtime:') -> broken
socket.channel('realtime:public:*') -> broken (see realtime:public below)
But these should
socket.channel('realtime:*') -> listen to changes in the database
socket.channel('realtime:public') -> listen to changes in the public schema
socket.channel('realtime:public:users') -> listen to changes in the users table
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?)
from realtime.
For auth, specialized socket APIs that hide the underlying database structure and some payload modifications.
from realtime.
Small example pushed for you @retendo. I used your code as a baseline so thanks for contributing
think the more important change should be the ".channel" in between join() and on( ... ).
Check out the difference between my first commit and my second: d4c9ece
Basically socket.channel()
returns the channel, and socket.channel.join()
returns the join event. So you were "accessing" the channel through the join
event.
Please keep me update on your proxy - if you can keep it generic enough I'll add it to the examples
folder.
from realtime.
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.
from realtime.
Closing now, feel free to reopen at any stage
from realtime.
Related Issues (20)
- Realtime version and release don't match HOT 1
- log_min_messages requires elevated privileges HOT 1
- Docker hub `latest` image tag is very old HOT 3
- What version of realtime is hosted Supabase using? HOT 1
- Add region to all Logger metadatas
- Realtime: Self Hosting - Docker Swarm mode HOT 6
- Docker-compose file appears to be broken HOT 40
- Unable to use null filters like 'parent IS NULL' in supabase realtime. HOT 3
- How is postgres binary data serialized?
- > Does supabase have null filters? HOT 1
- Self hosted : failed to connect: ** (Postgrex.Error) ssl not available HOT 1
- Startup error running migrations: table identifier does not refer to an existing ETS table HOT 8
- Erroneous public.test_tenant file from Supabase Realtime Migrations HOT 5
- Supabase Realtime Subscript Fails With Undefined Error (Possibly: `Auth error: tenant 'realtime-dev' not found` HOT 15
- supabase realtime not working HOT 26
- Seeds broken in latest docker image HOT 2
- horizontal scaling for self-hosted realtime servers, for broadcast and presence features HOT 5
- HTTP 431 & Realtime Subscriptions Failing HOT 11
- Realtime event broadcasting through REST calls does not work HOT 8
- Excessive logs being printed to STD OUT/ERR 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 realtime.