Skip to content

Commit

Permalink
Added Parallel applicative and also breakingly...
Browse files Browse the repository at this point in the history
...changed `template` and `apply` to work in parallel and renamed
`[upH|downH|h]asFailed` to `[upH|downH|h]asErrored`.
  • Loading branch information
polytypic committed Jan 2, 2019
1 parent c7cae19 commit 0d1c39d
Show file tree
Hide file tree
Showing 9 changed files with 631 additions and 402 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Karet XHR Changelog

## 0.7.0

Renamed
* `upHasFailed` to `upHasErrored`,
* `downHasFailed` to `downHasErrored`, and
* `hasFailed` to `hasErrored`
and also introduced new function
* `hasFailed`.

`template` and `apply` were changed to process XHRs in parallel using the newly
added `IdentityParallel` algebra, because that is what one more often wants.
Note that this doesn't change the behaviour of the `IdentitySucceeded` algebra.

## 0.6.7

`apply` was changed to accept both XHRs and plain values.

## 0.6.2

Fix work around for IE11 where `'progress'` events may be sent after `'load'`
Expand Down
637 changes: 352 additions & 285 deletions README.md

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions docs/setup.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
window.L = window.Kefir.partial.lenses
window.XHR = window.karet.xhr
window.log = function() {
var Kefir = window.Kefir
var log = console.log
var xs = []
for (let i = 0; i < arguments.length; ++i) {
var x = arguments[i]
xs.push(x instanceof Kefir.Observable ? x : Kefir.constant(x))
}
var log = console.log
function logs(xs) {
log.apply(console, xs)
}
Kefir.combine(xs).observe(logs, logs)
}
12 changes: 11 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "karet.xhr",
"version": "0.6.8",
"version": "0.7.0-0",
"description": "An observable wrapper for XMLHttpRequest using Kefir",
"module": "dist/karet.xhr.es.js",
"main": "dist/karet.xhr.cjs.js",
Expand Down Expand Up @@ -46,6 +46,7 @@
"eslint": "^5.11.1",
"express": "^4.16.4",
"kefir": "^3.8.5",
"kefir.ramda": "^0.26.0",
"klipse-github-docs-generator": "^0.3.7",
"livereload": "^0.7.0",
"mocha": "^5.2.0",
Expand Down
51 changes: 51 additions & 0 deletions src/delay-unsub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import * as I from 'infestines'
import * as K from 'kefir'

const TIMER = 't'
const SOURCE = 's'
const HANDLER = 'h'

const TYPE = 'type'
const VALUE = 'value'
const END = 'end'

const DelayUnsub = I.inherit(
function DelayUnsub(source) {
const self = this
K.Property.call(self)
self[SOURCE] = source
self[HANDLER] = self[TIMER] = 0
},
K.Property,
{
_onActivation() {
const self = this
if (self[TIMER]) {
clearTimeout(self[TIMER])
self[TIMER] = 0
} else {
self[SOURCE].onAny(
(self[HANDLER] = e => {
const t = e[TYPE]
if (t === VALUE) {
self._emitValue(e[VALUE])
} else if (t === END) {
self._emitEnd()
} else {
self._emitError(e[VALUE])
}
})
)
}
},
_onDeactivation() {
const self = this
self[TIMER] = setTimeout(() => {
self[SOURCE].offAny(self[HANDLER])
self[HANDLER] = self[TIMER] = 0
}, 0)
}
}
)

export const delayUnsub = source => new DelayUnsub(source)
Loading

0 comments on commit 0d1c39d

Please sign in to comment.