Closed elrhomariyounes closed 2 years ago
Would this work?
public class MyService
{
public readonly Supabase.Client client;
public MyService()
{
client = Supabase.Client.Initialize(supabaseUrl, supabaseKey, options);
}
}
Hello @acupofjose, Thank you for the quick reply. Here the Initialize will return a
Task<Supabase.Client>
public class MyService
{
public readonly Supabase.Client client;
public MyService()
{
// Get Result
client = Supabase.Client.Initialize(supabaseUrl, supabaseKey, options).Result;
}
}
Will that work? Or do you think we should transition to:
Supabase.Client Initialize(string, supabaseUrl, string supabaseKey, SupabaseOptions options);
// and
Task<Supabase.Client> InitializeAsync(string, supabaseUrl, string supabaseKey, SupabaseOptions options)
Yeah good idea! and if I'm not wrong the Postgrest client is not initialized when calling Supabase.Client.Initialize
That's correct, it's not supposed to be - it is supposed to be initialized on each call to From()
(this is the way that the supabase-js
library does it.)
Aaaalllllrighty. Changes have been pushed to both gotrue-csharp@2.0.0
and supabase-csharp@0.1.4-prerelease
that default to a synchronous API for initialization. The previous initializer can be found with Client.InitializeAsync(....)
. Let me know if that works for you!
Hello, I tried to make a sample todo project using Blazor Web Assembly and Supabase Todo Quick Start.
I made an AuthenticationService where I initialize the supabase client in the constructor, but the application crushed immediately when navigating to the component where my AuthenticationService is injected you can check the sample project to reproduce here.
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Cannot wait on monitors on this runtime.
System.PlatformNotSupportedException: Cannot wait on monitors on this runtime.
@elrhomariyounes sorry I've been pretty slow on responding to this. I'm not particularly familiar with Blazor - but it looks like it the exception is thrown from blocking the main thread on an async call. Is it possible to change to using InitializeAsync()
for your use case? The alternative is to change the gotrue API to require a synchronous call for SessionRetriever
, SessionPersistor
, and SessionDestroyer
. I'm not sure I want to require that.
Any thoughts?
Hello @acupofjose, Hope you're doing great.
I've been trying this days to figure out a solution without changing all this methods to run synchronously, but unfortunately no idea, I tried using InitializeAsync but I have to call .Result
to set the supabase client value and this will result to a blocking call same as Initialize.
Hello @acupofjose, Hope you're doing great.
I've been trying this days to figure out a solution without changing all this methods to run synchronously, but unfortunately no idea, I tried using InitializeAsync but I have to call
.Result
to set the supabase client value and this will result to a blocking call same as Initialize.
I have the same issue. Don't know how to make it works.
@gostan99 thanks for the report! Are you also attempting to use this on Blazor?
@gostan99 thanks for the report! Are you also attempting to use this on Blazor?
yes I am attempting to use this on Blazor. Seems that Blazor Webassembly does not support Websocket I think.
Found the problem! The Client
now defaults to not initializing Realtime
functionality unless specified. I've also removed problematic Task.Result
calls that were causing blazor issues.
Available in 0.1.5-prerelease
Hi Everyone, @acupofjose i was having trouble using to use the Realtime feature of Supabase on Blazor WebAssembly (Platform not supported exception) and found this thread. i do know that Blazor WASM supports System.Net.WebSocket.ClientWebSocket (they wrote specific implementation for blazor wasm) but i am not sure if WebSocketSharp supports Blazor WASM. is it possible to use supabase realtime on blazor wasm. if not is it feasable to replace the WebSocketSharp implementation with with ClientWebSocket in Supabae.Realtime. i am willing to contribute if needed!!
@syedqutub - Blazor is not a framework I'm familiar with, I've only worked on it with debugging on this project. As far as I've seen, WebsocketSharp
does not support Blazor WASM. Supabase would require a different client that is either specific for Blazor or more generalized that WebSocketSharp (with Blazor support). I gladly welcome any contributions you have!
@acupofjose Thanks alot for the reply!.
i do know that System.Net.WebSockets.ClientWebSocket
c;lass is supported on Blazor WASM. so am playing around with it. if i manage to come up with an implementation for the Supabase's Realtime Socket class. i will let you know!.
Bug report
Describe the bug
Hello, I have an issue, is there any workaround, the thing is if I want to have a service with the supabase client as a property how can I initialize the supabase client since the Initialize method is async for example :
I can't initialize the supabaseClient in the constructor