pubnub 0.1.0 pubnub: ^0.1.0 copied to clipboard
A simple PubNub wrapper in Dart.
// Copyright (c) 2016, Sebastian Nozzi. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.
import 'package:pubnub/pubnub.dart';
import 'user_interface.dart';
import 'js_interop.dart';
void main() {
final ui = new UserInterface();
final pubnubDemo = new PubNub(
publishKey: 'pub-a4ec9cdc-0120-4f9e-8f36-d1aba394abce',
subscribeKey: 'sub-ef818b5e-70db-11e1-97bc-3fa70795ed6c');
ui.onTextInput((txt) {
ui.resetInputField();
pubnubDemo.publish(channel: 'demo_tutorial',
message: new ChatMsg(text: txt));
});
pubnubDemo.subscribe('demo_tutorial');
pubnubDemo.addListener((PubNubEvent event){
String chatText = event.message.text;
ui.appendListItemWithText(chatText);
});
}