https://github.com/leftyio/talkjs
https://github.com/leftyio/talkjs
browser dart javascript-interop
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/leftyio/talkjs
- Owner: leftyio
- License: mit
- Created: 2018-02-06T09:25:05.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-12-28T13:33:06.000Z (over 4 years ago)
- Last Synced: 2026-02-19T08:10:45.588Z (2 months ago)
- Topics: browser, dart, javascript-interop
- Language: Dart
- Size: 34.2 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# TalkJs
Javascript interop for [TalkJs](https://talkjs.com)
See TalkJs [documentations](https://talkjs.com/docs/Getting_Started/index.html) documentations more infos
## Example
```dart
import 'dart:html';
import 'package:talkjs/talkjs.dart';
Future main() async {
addTalkJsScript();
await TalkJs.ready;
createInbox();
}
void createInbox() {
final me = User(
UserOptions()
..id = '12345'
..name = 'George Looney'
..email = 'george@looney.net'
..photoUrl = 'https://talkjs.com/docs/img/george.jpg'
..welcomeMessage = 'Hey there! How are you? :-)',
);
final talkSession = Session(
SessionOptions()
..appId = ''
..me = me,
);
final other = User(
UserOptions()
..id = '54321'
..name = 'Ronald Raygun'
..email = 'ronald@teflon.com'
..photoUrl = 'https://talkjs.com/docs/img/ronald.jpg'
..welcomeMessage = 'Hey there! Love to chat :-)',
);
final conversationId = TalkJs.oneOnOneId(me, other);
final conversation = talkSession.getOrCreateConversation(conversationId);
conversation.setParticipant(me);
conversation.setParticipant(other);
final inbox = TalkJsInbox(
talkSession.createInbox(
InboxOptions()..selected = conversation,
),
);
final el = document.getElementById('talkjs-container');
if (el == null) return;
inbox.mount(el);
}
```