Skip to content

Commit

Permalink
- new Askless version: 2.0.0 + CHANGELOG.md
Browse files Browse the repository at this point in the history
- removing useless TODO's on examples
- documentation/readme changes
- 'collection' & 'meta' dependencies added
  • Loading branch information
RodrigoBertotti committed Aug 2, 2021
1 parent 4a0c7b1 commit 57b6266
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 29 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# 2.0.0
- dart sdk updated: >=2.12.0 <3.0.0 (null safety)
- web support
- useDefaultLogger: default as false
- fix: accepting non-maps types on the "body" field of an update request
- other adjustments/fixes
- documentation and README changes
- code refactoring
- unit tests added
- examples updated to null safety
- new dependencies in pubspec.yaml

## 1.0.1

- Fix: prevent old connections data from getting in the way of the last successful connection attempt
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pubspec.yaml:
sdk: flutter
# Add this line:
askless: ^1.0.1
askless: ^2.0.0

4 - Import the package

Expand Down
2 changes: 1 addition & 1 deletion README_PORTUGUES.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pubspec.yaml:
sdk: flutter
# Adicione essa linha:
askless: ^1.0.1
askless: ^2.0.0

4 - Importe

Expand Down
2 changes: 1 addition & 1 deletion documentation/english_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The URL of the server, must start with `ws://` or `wss://`. Example: `ws://192.1

#### logger

Allow to customize the behavior of internal logs and enable/disable the default logger (optional).
Allow to customize the behavior of internal logs and enable the default logger (optional).

##### Params:

Expand Down
5 changes: 1 addition & 4 deletions example/catalog/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ android {
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.catalog"
minSdkVersion 16
targetSdkVersion 30
Expand All @@ -43,9 +42,7 @@ android {

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
signingConfig signingConfigs.debug
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/catalog/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'CatalogMainPage.dart';


final String ipv4Address = '192.168.2.1';
final String ipv4Address = '192.168.0.3';
final serverUrl = 'ws://'+ipv4Address+':3000';


Expand Down
3 changes: 0 additions & 3 deletions example/chat/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ android {
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.chat"
minSdkVersion 16
targetSdkVersion 30
Expand All @@ -43,8 +42,6 @@ android {

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/chat/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:askless/askless.dart';
import 'SignInPage.dart';


final String ipv4Address = '192.168.2.1';
final String ipv4Address = '192.168.0.3';
final serverUrl = 'ws://'+ipv4Address+':3000';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions example/tracking/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ android {
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.tracking"
minSdkVersion 16
targetSdkVersion 30
Expand All @@ -43,7 +42,6 @@ android {

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
Expand Down
2 changes: 1 addition & 1 deletion example/tracking/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:askless/askless.dart';

import 'TrackingApp.dart';

final serverUrl = 'ws://192.168.2.1:3000';
final serverUrl = 'ws://192.168.0.3:3000';

void main() {
AsklessClient.instance.init(
Expand Down
10 changes: 7 additions & 3 deletions lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const REQUEST_PREFIX = 'REQ-';
const LISTEN_PREFIX = 'LIS-';
const CLIENT_GENERATED_ID_PREFIX = 'CLIENT_GENERATED_ID-';

//TODO onupdate:
const CLIENT_LIBRARY_VERSION_NAME = '1.0.1';
const CLIENT_LIBRARY_VERSION_CODE = 2;
// TODO onupdate:
const CLIENT_LIBRARY_VERSION_NAME = '2.0.0';
const CLIENT_LIBRARY_VERSION_CODE = 3;

// TODO onupdate: CHECK README EN / PT (# Add this line: askless: ^2.0.0)

// TODO onupdate: add changelog
72 changes: 62 additions & 10 deletions lib/src/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ LoggerFunction _getDefaultLogger() => (String message, Level level, {additionalD
class Logger{
late final LoggerFunction doLog;

/// Allow to customize the behavior of internal logs and enable/disable the default logger (optional).
/// Allow to customize the behavior of internal logs and enable the default logger (optional).
///
/// [useDefaultLogger] If [true]: the default logger will be used (optional). Default: `false`
///
Expand Down Expand Up @@ -190,18 +190,15 @@ class AsklessClient {

/// Try to perform a connection with the server.
///
/// Returns the result of the connection attempt.
///
/// [ownClientId]: The ID of the user defined in your application.
/// This field must NOT be [null] when the user is logging in,
/// otherwise must be [null] (optional).
///
/// [headers]: Allows informing the token of the respective [ownClientId] (and/or additional data)
/// so that the server can be able to accept or deny the connection attempt (optional).
///
/// In the server side, you can implement [grantConnection](https://github.com/WiseTap/askless/blob/master/documentation/english_documentation.md#grantconnection)
/// to accept or deny connections attempts from the client.
///
/// Returns the result of the connection attempt.
///
/// Example:
/// ```
/// AsklessClient.instance.connect(ownClientId: 1, headers: {
Expand Down Expand Up @@ -290,6 +287,17 @@ class AsklessClient {
/// If [false]: the field [requestTimeoutInSeconds] defined in the server side
/// will be the timeout.
///
/// Example
/// ```
/// AsklessClient.instance
/// .create(route: 'product',
/// body: {
/// 'name' : 'Video Game',
/// 'price' : 500,
/// 'discount' : 0.1
/// }
/// ).then((res) => print(res.isSuccess ? 'Success' : res.error!.code));
/// ```
Future<ResponseCli> create({required String route, required dynamic body, Map<String, dynamic> ? query, bool neverTimeout: false}) async {
assert(body!=null);
await _assertHasMadeConnection();
Expand All @@ -313,6 +321,19 @@ class AsklessClient {
/// If [false]: the field [requestTimeoutInSeconds] defined in the server side
/// will be the timeout.
///
/// Example
/// ```
/// AsklessClient.instance
/// .update(
/// route: 'allProducts',
/// query: {
/// 'nameContains' : 'game'
/// },
/// body: {
/// 'discount' : 0.8
/// }
/// ).then((res) => print(res.isSuccess ? 'Success' : res.error!.code));
/// ```
Future<ResponseCli> update({required String route, required dynamic body, Map<String, dynamic> ? query, bool neverTimeout: false}) async {
assert(body!=null);
await _assertHasMadeConnection();
Expand Down Expand Up @@ -366,7 +387,6 @@ class AsklessClient {
/// will be the timeout.
///
/// Example
///
/// ```
/// AsklessClient.instance
/// .read(route: 'allProducts',
Expand Down Expand Up @@ -402,6 +422,38 @@ class AsklessClient {
/// here can be added a filter to indicate to the server
/// which data this client will receive.
///
/// Example
/// ```
/// Listening listeningForNewGamingProducts;
///
/// @override
/// void initState() {
/// super.initState();
/// listeningForNewGamingProducts = AsklessClient.instance
/// .listen(route: 'allProducts',
/// query: {
/// 'nameContains' : 'game'
/// },
/// );
/// listeningForNewGamingProducts.stream.listen((newRealtimeData) {
/// List products = newRealtimeData.output;
/// products.forEach((singleProduct) {
/// print("New gaming product created: "+singleProduct['name']);
/// });
/// });
/// }
///
/// @override
/// void dispose() {
///
/// // IMPORTANT
/// // don't forget to close the stream
/// // to stop receiving data from the server
/// listeningForNewGamingProducts.close();
///
/// super.dispose();
/// }
/// ```
Listening listen({required String route, Map<String, dynamic> ? query,}) {
_assertHasMadeConnection();

Expand Down Expand Up @@ -535,7 +587,7 @@ class AsklessClient {
///
/// [serverUrl] The URL of the server, must start with [ws://] or [wss://]. Example: [ws://192.168.2.1:3000].
///
/// [logger] Allow to customize the behavior of internal logs and enable/disable the default logger (optional).
/// [logger] Allow to customize the behavior of internal logs and enable the default logger (optional).
///
/// [projectName] Name for this project (optional).
/// If [!= null]: the field [projectName] on server side must have the same name (optional).
Expand Down Expand Up @@ -567,7 +619,7 @@ typedef OnDisconnect({RespondError error});
/// Example: in [dispose] implementation of Scaffold
/// that uses this stream.
///
/// [close] Stop receiving realtime data from server using [Listening.stream].
/// [close] Stop receiving realtime data from server using [Listening.stream].
///
class Listening {
/// Listening for new data from the server after call the method [wsListen].
Expand All @@ -579,7 +631,7 @@ class Listening {
/// Example: in [dispose] implementation of Scaffold
/// that uses this stream.
///
/// [close] Stop receiving realtime data from server using [Listening.stream].
/// [close] Stop receiving realtime data from server using [Listening.stream].
///
final String clientRequestId;
//Um id gerado pelo cliente que representa
Expand Down
4 changes: 3 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: askless
description: Flutter client of Askless framework, which facilitates building realtime servers for JavaScript and Flutter Apps

version: 1.0.1 # TODO onupdate:
version: 2.0.0 # TODO onupdate:

environment:
sdk: ">=2.12.0 <3.0.0"
Expand All @@ -23,6 +23,8 @@ dependencies:
web_socket_channel: ^2.1.0
injectable: ^1.4.1
get_it: ^7.2.0
collection: ^1.15.0
meta: ^1.3.0

dev_dependencies:
test: ^1.17.10
Expand Down

0 comments on commit 57b6266

Please sign in to comment.