Skip to content

Commit

Permalink
docs: remove isolate from supabase client (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Apr 19, 2023
1 parent 971227c commit 1aff43a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 38 deletions.
4 changes: 1 addition & 3 deletions docs/guides/shelf.mdx
Expand Up @@ -34,7 +34,7 @@ void main() {
fetch: (request) async {
final app = Router();

app.get('/', (request, String id) async {
app.get('/', (request) async {
return Response.ok('Welcome to Dart Edge!');
});

Expand All @@ -49,5 +49,3 @@ void main() {
```
Alternatively, you could return a [`Pipeline`](https://pub.dev/documentation/shelf/latest/shelf/Pipeline-class.html) handler to apply middleware to your requests.
35 changes: 0 additions & 35 deletions docs/platform/supabase/client.mdx
Expand Up @@ -21,40 +21,6 @@ Next, install the Dart Edge HTTP Client:
dart pub add edge_http_client
```

Next, install the `yet_another_json_isolate` package (more on this next...):

```sh
dart pub add yet_another_json_isolate
```

### Create an Isolate stub

> Please note; this code will be extracted out at some point so this step will be easier.
The Supabase client uses isolates to parse JSON off the main thread. This is not supported in Dart Edge, so we need to create a stub that will allow the client to run it in the main thread.

```dart
import 'package:yet_another_json_isolate/yet_another_json_isolate.dart';
class EdgeIsolate implements YAJsonIsolate {
@override
Future decode(String json) {
return Future.value(jsonDecode(json));
}
@override
Future<void> dispose() async {}
@override
Future<String> encode(Object? json) {
return Future.value(jsonEncode(json));
}
@override
Future<void> initialize() async {}
}
```

## Usage

Within your `lib/main` file, import the `supabase` package and create a new instance of the client:
Expand All @@ -69,7 +35,6 @@ void main() {
'https://<your-project-id>.supabase.co',
'your-anon-key',
httpClient: EdgeHttpClient(),
isolate: EdgeIsolate(),
);
SupabaseFunctions(fetch: (request) async {
Expand Down

0 comments on commit 1aff43a

Please sign in to comment.