Created
July 18, 2021 08:57
-
-
Save hamzamu/a4d6e6ff6305cc10a6db2ebde51def77 to your computer and use it in GitHub Desktop.
Flutter_Meteor_Connect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:enhanced_meteorify/enhanced_meteorify.dart'; | |
// Meteor connect | |
void connectWS() async { | |
try { | |
var status = await Meteor.connect('ws://localhost:3000/websocket'); | |
print('Subscribed at: ws://localhost:3000/websocket'); | |
subPosts(); | |
} catch (error) { | |
print(error); | |
} | |
} | |
// Subscribe to posts collection | |
void subPosts() async { | |
var subscriptionId = await Meteor.subscribe('posts'); | |
} | |
// Run flutter app | |
void main() async { | |
connectWS(); | |
// | |
runApp(MyApp()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment