Skip to content

Commit

Permalink
Do not force rxjs
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcardeenas committed Jun 10, 2019
1 parent b8b4435 commit ee56179
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
dist
session
session
sample
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# 🤖sulla

Javascript whatsapp framework (web whatsapp driver)
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sulla",
"version": "1.0.0",
"version": "1.0.1",
"description": "Javascript whatsapp framework",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
7 changes: 2 additions & 5 deletions src/api/whatsapp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Page } from 'puppeteer';
import { Subject } from 'rxjs';
import { ExposedFn } from './functions/exposed.enum';
import { Chat } from './model/chat';
import { Contact } from './model/contact';
Expand All @@ -24,12 +23,10 @@ export class Whatsapp {
* Listens to messages received
* @returns Observable stream of messages
*/
public onMessage() {
const messageSubject = new Subject<Message>();
public onMessage(fn: (message: Message) => void) {
this.page.exposeFunction(ExposedFn.OnMessage, (message: Message) =>
messageSubject.next(message)
fn(message)
);
return messageSubject.asObservable();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/initializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const spinner = ora();
/**
* Should be called to initialize whatsapp client
*/
export const init = async () => {
export const create = async () => {
spinner.start('Initializing whatsapp');
let waPage = await initWhatsapp();
spinner.succeed();
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { Chat, Contact, Message } from './api/model';
export { Whatsapp } from './api/whatsapp';
export { init } from './controllers/initializer';
export { create } from './controllers/initializer';
1 change: 0 additions & 1 deletion src/lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ WAPI.waitNewMessages(false, function (data) {
window[ExposedFn.OnMessage](message);
});
});

0 comments on commit ee56179

Please sign in to comment.