eventric
Version:
behavior-first application development
65 lines (40 loc) • 1.58 kB
text/coffeescript
class Remote
: [
'command'
'query'
'findDomainEventsByName'
'findDomainEventsByNameAndAggregateId'
]
constructor: () ->
Projection = require 'eventric/projection'
inmemoryRemote = require 'eventric-remote-inmemory'
= {}
= {}
= new Projection @
inmemoryRemote.client
()
_exposeRpcOperationsAsMemberFunctions: ->
Remote.ALLOWED_RPC_OPERATIONS.forEach (rpcOperation) =>
@[rpcOperation] = =>
rpcOperation, arguments
subscribeToAllDomainEvents: (handlerFn) ->
.subscribe , handlerFn
subscribeToDomainEvent: (domainEventName, handlerFn) ->
.subscribe , domainEventName, handlerFn
subscribeToDomainEventWithAggregateId: (domainEventName, aggregateId, handlerFn) ->
.subscribe , domainEventName, aggregateId, handlerFn
unsubscribeFromDomainEvent: (subscriberId) ->
.unsubscribe subscriberId
_rpc: (functionName, args) ->
.rpc
contextName:
functionName: functionName
args: Array.prototype.slice.call args
setClient: (client) ->
= client
@
initializeProjection: (projectionObject, params) ->
return .initializeInstance projectionObject, params
destroyProjectionInstance: (projectionId) ->
.destroyInstance projectionId, @
module.exports = Remote