meteorify 1.0.2

Meteorify #

Pub

A Dart package to interact with the Meteor framework.

Connect your web or flutter apps, written in Dart, to the Meteor framework.

Features #

  • Connect to Meteor server
  • Use Meteor Subscriptions
  • Meteor Authentication
  • Call custom Methods on Meteor
  • Access underlying databases

Dependency #

Add this to your package's pubspec.yaml file:

dependencies:
  meteorify: ^1.0.1

Usage #

Capturing the result of operations #

You can use either the then-catchError or await syntax to capture the result of operations and handle errors.

I'll be using the await syntax in this documentation to keep it short and straight. You can use either catchError on Future object or try/catch syntax to catch errors.

Connection Operations #

Connecting with Meteor #

Using then-catchError:

import 'package:meteorify/meteorify.dart';

main() async{
  Meteor.connect("ws://example.meteor.com/websocket")
      .then((status){
          // Do something after connection is successful
      })
      .catchError((error){
          print(error);
          //Handle error
      });
}

Using await:

import 'package:meteorify/meteorify.dart';

main() async{
  try{
      var status = await Meteor.connect("ws://example.meteor.com/websocket");
      // Do something after connection is successful
  }catch(error){
      print(error);
      //Handle error
  }
}

Check connection status #

var isConnected = Meteor.isConnected;		

Disconnect from server #

Meteor.disconnect();

Subscriptions #

Subscribe to Data #

var subscriptionId = await Meteor.subscribe(subscriptionName);

Unsubscribe from Data #

await Meteor.unsubscribe(subscriptionId);

Get subscribed data/collection #

SubscribedCollection collection = await Meteor.collection(collectionName);
//collection.find({selectors});
//collection.findAll();
//collection.findOne(id);

Authentication #

Creating New Account #

var userId = await Accounts.createUser(username,email,password,profileOptions);

Login #

  1. Login with password

    String loginToken = await Meteor.loginWithPassword(email,password);
    
  2. Login with token

    String token = await Meteor.loginWithToken(loginToken);
    
  3. Change Password (need to be logged in)

    String result = await Accounts.changePassword(oldPassword,newPassword);
    
  4. Forgot Password

    String result = await Accounts.forgotPassword(email);
    
  5. Reset Password

    String result = await Accounts.resetPassword(resetToken,newPassword);
    
  6. Logout

    await Meteor.logout();
    
  7. Get logged in userId

    String userId = Meteor.currentUserId;
    
  8. Check if logged in

    bool isLoggedIn = Meteor.isLoggedIn();
    
  9. Get current user as map

    Map<String,dynamic> currentUser = await Meteor.userAsMap();
    

Call Custom Methods #

Defining custom methods in meteor server #

export const helloWorld = new ValidatedMethod({
  name: 'hello',
  validate: null,
  run({ firstname,lastname }) {
    const message = "hello "+firstname+" "+lastname;
    console.log(message);
    return message;
  },
});

Invoking custom methods #

var result = await Meteor.client.call("hello",[{"firstname":"Shivam","lastname":"Arora"}]);
print(result.reply);

Using Mongo Databases to manage data #

Meteorify uses the mongo_dart package internally to provide access to actual database.

For more instructions regarding use of mongo_dart , visit their mongo_dart guide.

Get Meteor Database #

import 'package:mongo_dart/mongo_dart.dart';

Db db = await Meteor.getMeteorDatabase();

Get custom database #

import 'package:mongo_dart/mongo_dart.dart';

Db db = await Meteor.getCustomDatabase(dbUrl);
await db.open();

Get collection #

import 'package:mongo_dart/mongo_dart.dart';

DbCollection collection = await db.collection("collectionName");

1.0.2 #

  • Provided a method to call serviceMethods exported from Meteor using Meteor.call().
  • Provided documentation for most of the classes and methods.

1.0.1 #

  • Improve package health and fix analysis issues

1.0.0 #

  • Initial version, created by ShivamArora
  • Features
    • Connect to Meteor server
    • Use Meteor Subscriptions
    • Meteor Authentication
    • Call Custom Methods on Meteor
    • Access underlying databases

example/meteorify_example.dart

main() {

}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  meteorify: ^1.0.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:meteorify/meteorify.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
55
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
78
Learn more about scoring.

We analyzed this package on Aug 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, other

Primary library: package:meteorify/meteorify.dart with components: io.

Health suggestions

Format lib/src/accounts/accounts.dart.

Run dartfmt to format lib/src/accounts/accounts.dart.

Format lib/src/meteor/meteor.dart.

Run dartfmt to format lib/src/meteor/meteor.dart.

Format lib/src/meteor/subscribed_collection.dart.

Run dartfmt to format lib/src/meteor/subscribed_collection.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
ddp ^0.0.9 0.0.13
mongo_dart ^0.3.5 0.3.5
Transitive dependencies
async 2.3.0
bson 0.3.2
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.1+1
fixnum 0.10.9
logging 0.11.3+2
matcher 0.12.5
meta 1.1.7
mongo_dart_query 0.3.2
more 1.18.0
path 1.6.4
pool 1.4.0
quiver 2.0.5
stack_trace 1.9.3
tuple 1.0.2
typed_data 1.1.6
uuid 2.0.2
Dev dependencies
pedantic ^1.0.0
test ^1.0.0