Skip to content

Commit

Permalink
Voting: partial application subscription methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bpierre committed Aug 24, 2020
1 parent 2d2cc88 commit 0278280
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
12 changes: 6 additions & 6 deletions packages/connect-voting/src/models/Vote.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {
SubscriptionCallback,
SubscriptionHandler,
} from '@aragon/connect-types'
import { SubscriptionCallback, SubscriptionResult } from '@aragon/connect-types'
import { subscription } from '@aragon/connect-core'
import { IVotingConnector, VoteData } from '../types'
import Cast from './Cast'

Expand Down Expand Up @@ -42,7 +40,9 @@ export default class Vote {
return this.#connector.castsForVote(this.id, first, skip)
}

onCasts(callback: SubscriptionCallback<Cast[]>): SubscriptionHandler {
return this.#connector.onCastsForVote(this.id, callback)
onCasts(callback?: SubscriptionCallback<Cast[]>): SubscriptionResult<Cast[]> {
return subscription<Cast[]>(callback, (callback) =>
this.#connector.onCastsForVote(this.id, callback)
)
}
}
14 changes: 6 additions & 8 deletions packages/connect-voting/src/models/Voting.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {
Address,
SubscriptionCallback,
SubscriptionHandler,
SubscriptionResult,
} from '@aragon/connect-types'
import { subscription } from '@aragon/connect-core'
import { IVotingConnector } from '../types'
import Vote from './Vote'

Expand All @@ -25,13 +26,10 @@ export default class Voting {

onVotes(
{ first = 1000, skip = 0 } = {},
callback: SubscriptionCallback<Vote[]>
): SubscriptionHandler {
return this.#connector.onVotesForApp(
this.#appAddress,
callback,
first,
skip
callback?: SubscriptionCallback<Vote[]>
): SubscriptionResult<Vote[]> {
return subscription<Vote[]>(callback, (callback) =>
this.#connector.onVotesForApp(this.#appAddress, callback, first, skip)
)
}
}

0 comments on commit 0278280

Please sign in to comment.