@deckdeckgo/slide-poll
Advanced tools
Comparing version 1.0.0-beta.1 to 1.0.0-beta.2
@@ -0,1 +1,15 @@ | ||
<a name="1.0.0-beta.2"></a> | ||
# 1.0.0-beta.2 (2019-12-01) | ||
### Features | ||
* remove RxJS and use callbacks instead | ||
<a name="1.0.0-beta.1-1"></a> | ||
# 1.0.0-beta.1-1 (2019-11-30) | ||
### Features | ||
* add a CSS variable for the `font-size` of the slot `how-to` | ||
<a name="1.0.0-beta.1"></a> | ||
@@ -2,0 +16,0 @@ # 1.0.0-beta.1 (2019-11-30) |
import { h, Host } from "@stencil/core"; | ||
import { Subject } from 'rxjs'; | ||
import { debounceTime, take } from 'rxjs/operators'; | ||
import { debounce } from '@deckdeckgo/utils'; | ||
@@ -22,3 +20,2 @@ import { hideLazyLoadImages, afterSwipe, lazyLoadContent } from '@deckdeckgo/slide-utils'; | ||
this.answeredOnce = false; | ||
this.updateChart = new Subject(); | ||
this.onResizeContent = async () => { | ||
@@ -29,11 +26,3 @@ await this.initSize(); | ||
}; | ||
} | ||
async componentWillLoad() { | ||
await this.initAnswerSlots(); | ||
this.voteSubscription = this.communicationService.watchVote().subscribe((answer) => { | ||
this.answeredOnce = true; | ||
this.answers[`answer-${answer}`]++; | ||
this.updateChart.next(); | ||
}); | ||
this.updateChartSubscription = this.updateChart.pipe(debounceTime(500)).subscribe(async () => { | ||
this.updateChartCallback = async () => { | ||
await this.updateChartAnswersData(); | ||
@@ -44,8 +33,4 @@ if (this.chartData && this.chartData.length >= 1) { | ||
} | ||
}); | ||
} | ||
async componentDidLoad() { | ||
await hideLazyLoadImages(this.el); | ||
this.initWindowResize(); | ||
this.pollKeySubscription = this.communicationService.watchPollKey().subscribe(async (key) => { | ||
}; | ||
this.updatePollKeyCallback = async (key) => { | ||
if (key) { | ||
@@ -56,16 +41,31 @@ this.oldPollKey = this.pollKey; | ||
} | ||
}); | ||
}; | ||
this.updateVoteCallback = async (answer) => { | ||
this.answeredOnce = true; | ||
this.answers[`answer-${answer}`]++; | ||
this.debounceUpdateChart(); | ||
}; | ||
this.updatePollAfterRetrieveCallback = async (poll) => { | ||
this.answeredOnce = true; | ||
if (poll && poll.poll) { | ||
this.chartData = []; | ||
this.chartData.push(poll.poll); | ||
await this.initAnswersData(); | ||
await drawChart(this.el, this.chartWidth, this.chartHeight); | ||
await initHowTo(this.el, this.pollKey); | ||
} | ||
this.pollConnected.emit(); | ||
}; | ||
this.debounceUpdateChart = debounce(this.updateChartCallback, 500); | ||
} | ||
async componentWillLoad() { | ||
await this.initAnswerSlots(); | ||
} | ||
async componentDidLoad() { | ||
await hideLazyLoadImages(this.el); | ||
this.initWindowResize(); | ||
this.slideDidLoad.emit(); | ||
} | ||
async componentDidUnload() { | ||
await this.communicationService.disconnect(); | ||
if (this.voteSubscription) { | ||
this.voteSubscription.unsubscribe(); | ||
} | ||
if (this.updateChartSubscription) { | ||
this.updateChartSubscription.unsubscribe(); | ||
} | ||
if (this.pollKeySubscription) { | ||
this.pollKeySubscription.unsubscribe(); | ||
} | ||
await this.communicationService.disconnect(this.pollKey); | ||
} | ||
@@ -172,5 +172,5 @@ componentDidUpdate() { | ||
} | ||
await this.communicationService.disconnect(); | ||
await this.communicationService.disconnect(this.pollKey); | ||
if (this.chartData && this.chartData.length >= 1) { | ||
await this.communicationService.connect(this.socketUrl, this.socketPath, this.chartData[0]); | ||
await this.communicationService.connect(this.socketUrl, this.socketPath, this.chartData[0], this.updatePollKeyCallback, this.updateVoteCallback); | ||
} | ||
@@ -182,15 +182,4 @@ } | ||
} | ||
this.communicationService.watchPoll().pipe(take(1)).subscribe(async (poll) => { | ||
this.answeredOnce = true; | ||
if (poll && poll.poll) { | ||
this.chartData = []; | ||
this.chartData.push(poll.poll); | ||
await this.initAnswersData(); | ||
await drawChart(this.el, this.chartWidth, this.chartHeight); | ||
await initHowTo(this.el, this.pollKey); | ||
} | ||
this.pollConnected.emit(); | ||
}); | ||
await this.communicationService.disconnect(); | ||
await this.communicationService.retrieve(this.socketUrl, this.socketPath, this.pollKey); | ||
await this.communicationService.disconnect(this.pollKey); | ||
await this.communicationService.retrieve(this.socketUrl, this.socketPath, this.pollKey, this.updateVoteCallback, this.updatePollAfterRetrieveCallback); | ||
} | ||
@@ -202,3 +191,3 @@ async updatePoll() { | ||
if (this.chartData && this.chartData.length >= 1) { | ||
await this.communicationService.update(this.chartData[0]); | ||
await this.communicationService.update(this.chartData[0], this.pollKey); | ||
} | ||
@@ -205,0 +194,0 @@ } |
import * as io from 'socket.io-client'; | ||
import { BehaviorSubject, Subject } from 'rxjs'; | ||
import { take } from 'rxjs/operators'; | ||
export class CommunicationService { | ||
constructor() { | ||
this.pollKey = new BehaviorSubject(undefined); | ||
this.vote = new Subject(); | ||
this.poll = new Subject(); | ||
} | ||
connect(url, path, poll) { | ||
connect(url, path, poll, updatePollKey, updateVote) { | ||
return new Promise(async (resolve) => { | ||
@@ -30,6 +23,6 @@ if (this.socket) { | ||
this.socket.on('poll_key', async (data) => { | ||
this.pollKey.next(data); | ||
updatePollKey(data); | ||
}); | ||
this.socket.on('vote', async (answer) => { | ||
this.vote.next(answer); | ||
updateVote(answer); | ||
}); | ||
@@ -39,3 +32,3 @@ resolve(); | ||
} | ||
retrieve(url, path, pollKey) { | ||
retrieve(url, path, pollKey, updateVote, updatePollAfterRetrieve) { | ||
return new Promise(async (resolve) => { | ||
@@ -60,6 +53,6 @@ if (this.socket) { | ||
this.socket.on('poll_desc', async (data) => { | ||
this.poll.next(data); | ||
updatePollAfterRetrieve(data); | ||
}); | ||
this.socket.on('vote', async (answer) => { | ||
this.vote.next(answer); | ||
updateVote(answer); | ||
}); | ||
@@ -69,3 +62,3 @@ resolve(); | ||
} | ||
disconnect() { | ||
disconnect(pollKey) { | ||
return new Promise((resolve) => { | ||
@@ -76,16 +69,14 @@ if (!this.socket) { | ||
} | ||
this.watchPollKey().pipe(take(1)).subscribe((key) => { | ||
if (key) { | ||
this.socket.emit('leave', { | ||
key: key | ||
}); | ||
} | ||
this.socket.removeAllListeners(); | ||
this.socket.disconnect(); | ||
this.socket = undefined; | ||
resolve(); | ||
}); | ||
if (pollKey) { | ||
this.socket.emit('leave', { | ||
key: pollKey | ||
}); | ||
} | ||
this.socket.removeAllListeners(); | ||
this.socket.disconnect(); | ||
this.socket = undefined; | ||
resolve(); | ||
}); | ||
} | ||
update(poll) { | ||
update(poll, pollKey) { | ||
return new Promise((resolve) => { | ||
@@ -96,18 +87,7 @@ if (!this.socket) { | ||
} | ||
this.watchPollKey().pipe(take(1)).subscribe((key) => { | ||
if (key) { | ||
this.socket.emit('update', { key: key, poll: poll }); | ||
} | ||
}); | ||
if (pollKey) { | ||
this.socket.emit('update', { key: pollKey, poll: poll }); | ||
} | ||
}); | ||
} | ||
watchPollKey() { | ||
return this.pollKey.asObservable(); | ||
} | ||
watchVote() { | ||
return this.vote.asObservable(); | ||
} | ||
watchPoll() { | ||
return this.poll.asObservable(); | ||
} | ||
} |
@@ -1,1 +0,1 @@ | ||
import{p as e,b as t}from"./p-d1b1a7f8.js";e().then(e=>t([["p-0bb8wwid",[[1,"deckgo-slide-poll",{socketUrl:[513,"socket-url"],socketPath:[513,"socket-path"],connectPollSocket:[4,"connect-poll-socket"],pollLink:[513,"poll-link"],pollKey:[1537,"poll-key"],customActions:[516,"custom-actions"],customBackground:[516,"custom-background"],chartWidth:[32],chartHeight:[32],chartData:[32],answeredOnce:[32],beforeSwipe:[64],afterSwipe:[64],lazyLoadContent:[64],revealContent:[64],hideContent:[64],resizeContent:[64],update:[64],isAnswered:[64]}]]]],e)); | ||
import{p as e,b as t}from"./p-d1b1a7f8.js";e().then(e=>t([["p-edqjdzsc",[[1,"deckgo-slide-poll",{socketUrl:[513,"socket-url"],socketPath:[513,"socket-path"],connectPollSocket:[4,"connect-poll-socket"],pollLink:[513,"poll-link"],pollKey:[1537,"poll-key"],customActions:[516,"custom-actions"],customBackground:[516,"custom-background"],chartWidth:[32],chartHeight:[32],chartData:[32],answeredOnce:[32],beforeSwipe:[64],afterSwipe:[64],lazyLoadContent:[64],revealContent:[64],hideContent:[64],resizeContent:[64],update:[64],isAnswered:[64]}]]]],e)); |
@@ -1,1 +0,1 @@ | ||
System.register(["./p-602a0fe4.system.js"],(function(){"use strict";var e,t;return{setters:[function(o){e=o.p;t=o.b}],execute:function(){e().then((function(e){return t([["p-qsgevlw3.system",[[1,"deckgo-slide-poll",{socketUrl:[513,"socket-url"],socketPath:[513,"socket-path"],connectPollSocket:[4,"connect-poll-socket"],pollLink:[513,"poll-link"],pollKey:[1537,"poll-key"],customActions:[516,"custom-actions"],customBackground:[516,"custom-background"],chartWidth:[32],chartHeight:[32],chartData:[32],answeredOnce:[32],beforeSwipe:[64],afterSwipe:[64],lazyLoadContent:[64],revealContent:[64],hideContent:[64],resizeContent:[64],update:[64],isAnswered:[64]}]]]],e)}))}}})); | ||
System.register(["./p-602a0fe4.system.js"],(function(){"use strict";var e,t;return{setters:[function(o){e=o.p;t=o.b}],execute:function(){e().then((function(e){return t([["p-irw3ghos.system",[[1,"deckgo-slide-poll",{socketUrl:[513,"socket-url"],socketPath:[513,"socket-path"],connectPollSocket:[4,"connect-poll-socket"],pollLink:[513,"poll-link"],pollKey:[1537,"poll-key"],customActions:[516,"custom-actions"],customBackground:[516,"custom-background"],chartWidth:[32],chartHeight:[32],chartData:[32],answeredOnce:[32],beforeSwipe:[64],afterSwipe:[64],lazyLoadContent:[64],revealContent:[64],hideContent:[64],resizeContent:[64],update:[64],isAnswered:[64]}]]]],e)}))}}})); |
@@ -22,6 +22,4 @@ import { EventEmitter } from '../../stencil.core'; | ||
private answeredOnce; | ||
private updateChart; | ||
private pollKeySubscription; | ||
private voteSubscription; | ||
private updateChartSubscription; | ||
private readonly debounceUpdateChart; | ||
constructor(); | ||
componentWillLoad(): Promise<void>; | ||
@@ -42,2 +40,6 @@ componentDidLoad(): Promise<void>; | ||
private updatePoll; | ||
private updateChartCallback; | ||
private updatePollKeyCallback; | ||
private updateVoteCallback; | ||
private updatePollAfterRetrieveCallback; | ||
beforeSwipe(_enter: boolean, _reveal: boolean): Promise<boolean>; | ||
@@ -44,0 +46,0 @@ afterSwipe(): Promise<void>; |
@@ -1,15 +0,8 @@ | ||
import { Observable } from 'rxjs'; | ||
import { DeckdeckgoPollQuestion, DeckdeckgoPoll } from '@deckdeckgo/types'; | ||
import { DeckdeckgoPollQuestion } from '@deckdeckgo/types'; | ||
export declare class CommunicationService { | ||
private socket; | ||
private pollKey; | ||
private vote; | ||
private poll; | ||
connect(url: string, path: string, poll: DeckdeckgoPollQuestion): Promise<void>; | ||
retrieve(url: string, path: string, pollKey: string): Promise<void>; | ||
disconnect(): Promise<void>; | ||
update(poll: DeckdeckgoPollQuestion): Promise<void>; | ||
watchPollKey(): Observable<string | undefined>; | ||
watchVote(): Observable<string>; | ||
watchPoll(): Observable<DeckdeckgoPoll>; | ||
connect(url: string, path: string, poll: DeckdeckgoPollQuestion, updatePollKey: Function, updateVote: Function): Promise<void>; | ||
retrieve(url: string, path: string, pollKey: string, updateVote: Function, updatePollAfterRetrieve: Function): Promise<void>; | ||
disconnect(pollKey: string): Promise<void>; | ||
update(poll: DeckdeckgoPollQuestion, pollKey: string): Promise<void>; | ||
} |
{ | ||
"name": "@deckdeckgo/slide-poll", | ||
"version": "1.0.0-beta.1", | ||
"version": "1.0.0-beta.2", | ||
"description": "Interact with your audience, add a live poll to your presentation", | ||
@@ -27,3 +27,2 @@ "main": "dist/index.js", | ||
"@deckdeckgo/utils": "^1.0.0-rc.2", | ||
"rxjs": "^6.5.3", | ||
"socket.io-client": "^2.3.0" | ||
@@ -30,0 +29,0 @@ }, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
3
1575574
33534
- Removedrxjs@^6.5.3
- Removedrxjs@6.6.7(transitive)
- Removedtslib@1.14.1(transitive)