diff --git a/README.md b/README.md index 12f013f..f400677 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,6 @@ dependencies: ## Features and Roadmap -Connection related features - - ✅ Connect to a server - ✅ Setting client configuration - ✅ Automatic reconnect with backoff algorithm diff --git a/example/main.dart b/example/main.dart new file mode 100644 index 0000000..696fcf6 --- /dev/null +++ b/example/main.dart @@ -0,0 +1,3 @@ +import 'package:spinify/spinify.dart'; + +void main() => Spinify(); diff --git a/lib/src.old/client/config.dart b/lib/src.old/client/config.dart index 37b8f20..d5c125f 100644 --- a/lib/src.old/client/config.dart +++ b/lib/src.old/client/config.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:meta/meta.dart'; + import '../model/pubspec.yaml.g.dart'; /// Token used for authentication @@ -17,7 +18,7 @@ typedef SpinifyToken = String; /// /// {@category Client} /// {@category Entity} -typedef SpinifyTokenCallback = FutureOr Function(); +typedef SpinifyTokenCallback = Future Function(); /// Callback to get initial connection payload data. /// @@ -25,7 +26,7 @@ typedef SpinifyTokenCallback = FutureOr Function(); /// /// {@category Client} /// {@category Entity} -typedef SpinifyConnectionPayloadCallback = FutureOr?> Function(); +typedef SpinifyConnectionPayloadCallback = Future?> Function(); /// {@template spinify_config} /// Spinify client common options. diff --git a/lib/src.old/client/spinify.dart b/lib/src.old/client/spinify.dart index f443180..6314c83 100644 --- a/lib/src.old/client/spinify.dart +++ b/lib/src.old/client/spinify.dart @@ -408,7 +408,7 @@ base mixin SpinifyConnectionMixin } @override - FutureOr ready() async { + Future ready() async { try { switch (state) { case SpinifyState$Disconnected _: @@ -767,7 +767,7 @@ base mixin SpinifyQueueMixin on SpinifyBase { _eventQueue.push('publish', () => super.publish(channel, data)); /* @override - FutureOr ready() => _eventQueue.push('ready', super.ready); */ + Future ready() => _eventQueue.push('ready', super.ready); */ @override Future presence(String channel) => diff --git a/lib/src.old/client/spinify_interface.dart b/lib/src.old/client/spinify_interface.dart index 5158298..c3e9c88 100644 --- a/lib/src.old/client/spinify_interface.dart +++ b/lib/src.old/client/spinify_interface.dart @@ -31,7 +31,7 @@ abstract interface class ISpinify /// Ready resolves when client successfully connected. /// Throws exceptions if called not in connecting or connected state. - FutureOr ready(); + Future ready(); /// Disconnect from the server. Future disconnect([ diff --git a/lib/src.old/subscription/client_subscription_impl.dart b/lib/src.old/subscription/client_subscription_impl.dart index 90d9abe..6f17eb0 100644 --- a/lib/src.old/subscription/client_subscription_impl.dart +++ b/lib/src.old/subscription/client_subscription_impl.dart @@ -310,7 +310,7 @@ base mixin SpinifyClientSubscriptionSubscribeMixin /// Await for subscription to be ready. @override - FutureOr ready() async { + Future ready() async { try { switch (state) { case SpinifySubscriptionState$Unsubscribed _: diff --git a/lib/src.old/subscription/server_subscription_impl.dart b/lib/src.old/subscription/server_subscription_impl.dart index 0297568..35ea2ad 100644 --- a/lib/src.old/subscription/server_subscription_impl.dart +++ b/lib/src.old/subscription/server_subscription_impl.dart @@ -254,7 +254,7 @@ base mixin SpinifyServerSubscriptionReadyMixin on SpinifyServerSubscriptionBase, SpinifyServerSubscriptionErrorsMixin { /// Await for subscription to be ready. @override - FutureOr ready() async { + Future ready() async { try { switch (state) { case SpinifySubscriptionState$Unsubscribed _: @@ -409,7 +409,7 @@ base mixin SpinifyServerSubscriptionQueueMixin final SpinifyEventQueue _eventQueue = SpinifyEventQueue(); @override - FutureOr ready() => _eventQueue.push( + Future ready() => _eventQueue.push( 'ready', super.ready, ); diff --git a/lib/src.old/subscription/subscription.dart b/lib/src.old/subscription/subscription.dart index f268ae4..6c2a4f9 100644 --- a/lib/src.old/subscription/subscription.dart +++ b/lib/src.old/subscription/subscription.dart @@ -55,7 +55,7 @@ sealed class SpinifySubscription { /// Await for subscription to be ready. /// Ready resolves when subscription successfully subscribed. /// Throws exceptions if called not in subscribing or subscribed state. - FutureOr ready(); + Future ready(); /// Publish data to current Subscription channel Future publish(List data); diff --git a/lib/src.old/subscription/subscription_config.dart b/lib/src.old/subscription/subscription_config.dart index 306a503..f7c322a 100644 --- a/lib/src.old/subscription/subscription_config.dart +++ b/lib/src.old/subscription/subscription_config.dart @@ -12,7 +12,7 @@ typedef SpinifySubscriptionToken = String; /// If method returns null then subscription will be established without token. /// {@category Subscription} /// {@category Entity} -typedef SpinifySubscriptionTokenCallback = FutureOr +typedef SpinifySubscriptionTokenCallback = Future Function(); /// Callback to set subscription payload data. @@ -21,7 +21,7 @@ typedef SpinifySubscriptionTokenCallback = FutureOr /// {@category Subscription} /// {@category Entity} -typedef SpinifySubscribePayloadCallback = FutureOr?> Function(); +typedef SpinifySubscribePayloadCallback = Future?> Function(); /// {@template subscription_config} /// Subscription common options diff --git a/lib/src.old/util/event_queue.dart b/lib/src.old/util/event_queue.dart index 85c4ef4..8207870 100644 --- a/lib/src.old/util/event_queue.dart +++ b/lib/src.old/util/event_queue.dart @@ -14,7 +14,7 @@ final class SpinifyEventQueue { bool _isClosed = false; /// Push it at the end of the queue. - Future push(String id, FutureOr Function() fn) { + Future push(String id, Future Function() fn) { final task = SpinifyTask(id, fn); _queue.add(task); _exec(); @@ -24,7 +24,7 @@ final class SpinifyEventQueue { /// Mark the queue as closed. /// The queue will be processed until it's empty. /// But all new and current events will be rejected with [WSClientClosed]. - FutureOr close() async { + Future close() async { _isClosed = true; await _processing; } @@ -64,7 +64,7 @@ final class SpinifyEventQueue { /// Task for the [SpinifyEventQueue]. class SpinifyTask { /// Create a new instance of [SpinifyTask]. - SpinifyTask(this.id, FutureOr Function() fn) + SpinifyTask(this.id, Future Function() fn) : _fn = fn, _completer = Completer(); @@ -73,13 +73,13 @@ class SpinifyTask { /// Unique identifier for the task. final String id; - final FutureOr Function() _fn; + final Future Function() _fn; /// Future of the task. Future get future => _completer.future; /// Execute the task. - FutureOr call() async { + Future call() async { final result = await _fn(); if (!_completer.isCompleted) { _completer.complete(result);