@effection/events
Advanced tools
Comparing version 2.0.0-preview.1-e00037d to 2.0.0-preview.2-0835ec2
# Changelog | ||
## 2.0.0-preview.2 | ||
### Patch Changes | ||
- 93ec0d6: Include CHANGELOGS and src with all packages | ||
- Updated dependencies [93ec0d6] | ||
- effection@2.0.0-preview.3 | ||
- @effection/subscription@2.0.0-preview.2 | ||
## 2.0.0-preview.1 | ||
@@ -4,0 +13,0 @@ |
@@ -48,4 +48,4 @@ 'use strict'; | ||
function on(task, source, name) { | ||
return subscription.Subscription.create(task, function (publish) { | ||
function on(source, name) { | ||
return subscription.createSubscribable(function (publish) { | ||
return function* () { | ||
@@ -52,0 +52,0 @@ var listener = function listener() { |
@@ -1,2 +0,2 @@ | ||
"use strict";var n=require("@effection/subscription");function r(n){return"function"==typeof n.addEventListener}function t(n,t,e){r(n)?n.addEventListener(t,e):n.on(t,e)}function e(n,t,e){r(n)?n.removeEventListener(t,e):n.off(t,e)}function o(n,r){return function(o){return function(i){var u=function(){for(var n=arguments.length,r=new Array(n),t=0;t<n;t++)r[t]=arguments[t];i(r)};o.ensure((function(){e(n,r,u)})),t(n,r,u)}}}exports.on=function(r,o,i){return n.Subscription.create(r,(function(n){return function*(){var r=function(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];return n(t)};try{t(o,i,r),yield}finally{e(o,i,r)}}}))},exports.once=o,exports.throwOnErrorEvent=function(n,r){return n.spawn((function*(){throw(yield o(r,"error"))[0]}))}; | ||
"use strict";var n=require("@effection/subscription");function r(n){return"function"==typeof n.addEventListener}function t(n,t,e){r(n)?n.addEventListener(t,e):n.on(t,e)}function e(n,t,e){r(n)?n.removeEventListener(t,e):n.off(t,e)}function o(n,r){return function(o){return function(i){var u=function(){for(var n=arguments.length,r=new Array(n),t=0;t<n;t++)r[t]=arguments[t];i(r)};o.ensure((function(){e(n,r,u)})),t(n,r,u)}}}exports.on=function(r,o){return n.createSubscribable((function(n){return function*(){var i=function(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];return n(t)};try{t(r,o,i),yield}finally{e(r,o,i)}}}))},exports.once=o,exports.throwOnErrorEvent=function(n,r){return n.spawn((function*(){throw(yield o(r,"error"))[0]}))}; | ||
//# sourceMappingURL=events.cjs.production.min.js.map |
@@ -1,2 +0,2 @@ | ||
import { Subscription } from '@effection/subscription'; | ||
import { createSubscribable } from '@effection/subscription'; | ||
@@ -46,4 +46,4 @@ function isEventTarget(target) { | ||
function on(task, source, name) { | ||
return Subscription.create(task, function (publish) { | ||
function on(source, name) { | ||
return createSubscribable(function (publish) { | ||
return function* () { | ||
@@ -50,0 +50,0 @@ var listener = function listener() { |
@@ -1,4 +0,3 @@ | ||
import { Task } from '@effection/core'; | ||
import { Subscription } from '@effection/subscription'; | ||
import { Subscribable } from '@effection/subscription'; | ||
import { EventSource } from './event-source'; | ||
export declare function on<T extends Array<unknown> = unknown[]>(task: Task, source: EventSource, name: string): Subscription<T, void>; | ||
export declare function on<T extends Array<unknown> = unknown[]>(source: EventSource, name: string): Subscribable<T, void>; |
{ | ||
"name": "@effection/events", | ||
"version": "2.0.0-preview.1-e00037d", | ||
"version": "2.0.0-preview.2-0835ec2", | ||
"description": "Helpers for listening to events with effection", | ||
@@ -24,4 +24,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"effection": "^2.0.0-preview.2", | ||
"@effection/subscription": "^2.0.0-preview.1" | ||
"effection": "^2.0.0-preview.3", | ||
"@effection/subscription": "^2.0.0-preview.2" | ||
}, | ||
@@ -28,0 +28,0 @@ "devDependencies": { |
import { Task } from '@effection/core'; | ||
import { Subscription } from '@effection/subscription'; | ||
import { createSubscribable, Subscribable } from '@effection/subscription'; | ||
import { EventSource, addListener, removeListener } from './event-source'; | ||
export function on<T extends Array<unknown> = unknown[]>(task: Task, source: EventSource, name: string): Subscription<T, void> { | ||
return Subscription.create(task, (publish) => function*() { | ||
export function on<T extends Array<unknown> = unknown[]>(source: EventSource, name: string): Subscribable<T, void> { | ||
return createSubscribable((publish) => function*() { | ||
let listener = (...args: T) => publish(args); | ||
@@ -9,0 +9,0 @@ try { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
26893
235