From 24449a3b516136eb9df62816f6e398c9827a3573 Mon Sep 17 00:00:00 2001 From: SandroMaglione Date: Mon, 25 Mar 2024 16:45:06 +0900 Subject: [PATCH] update examples --- examples/fpdart_http/lib/api.dart | 8 ++++---- examples/fpdart_http/lib/main.dart | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/fpdart_http/lib/api.dart b/examples/fpdart_http/lib/api.dart index 2c7d600..a464fc0 100644 --- a/examples/fpdart_http/lib/api.dart +++ b/examples/fpdart_http/lib/api.dart @@ -10,19 +10,19 @@ Effect get( }) => /// 2️⃣ Use the Do notation with the `gen` constructor - Effect.gen((_) async { + Effect.gen(($) async { /// 3️⃣ Extract the dependency using `env` (environment) - final client = _.sync(Effect.env()); + final client = $.sync(Effect.env()); /// 4️⃣ Perform a request, catch errors, extract the response - final response = await _.async(Effect.tryCatch( + final response = await $.async(Effect.tryCatch( execute: () => client.get(url, headers: headers), onError: (_, __) => const RequestError(), )); /// 5️⃣ Use plain dart code to check for valid status if (response.statusCode != 200) { - return _.sync(Effect.fail(const ResponseError())); + return $.sync(Effect.fail(const ResponseError())); } /// 6️⃣ Return extracted/valid response diff --git a/examples/fpdart_http/lib/main.dart b/examples/fpdart_http/lib/main.dart index 6542ac4..844bdd8 100644 --- a/examples/fpdart_http/lib/main.dart +++ b/examples/fpdart_http/lib/main.dart @@ -12,7 +12,8 @@ void main() async { () => print(response.body), ), ) - .runFuture( + .provide( http.Client(), - ); + ) + .runFuture(); }