@cycle/history
Advanced tools
Comparing version 7.1.0 to 7.2.0
@@ -0,1 +1,7 @@ | ||
## 7.2.0 (2019-07-01) | ||
* feat(history): complete support for history.push API (#890) ([efff1ce](https://github.com/cyclejs/cyclejs/commit/efff1ce)), closes [#890](https://github.com/cyclejs/cyclejs/issues/890) | ||
## 7.1.0 (2018-12-10) | ||
@@ -2,0 +8,0 @@ |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -21,3 +32,3 @@ var xstream_1 = require("xstream"); | ||
if (input.type === 'push') { | ||
history.push(input.pathname, input.state); | ||
history.push(__assign({}, input)); | ||
} | ||
@@ -24,0 +35,0 @@ if (input.type === 'replace') { |
@@ -5,7 +5,13 @@ import { Stream, MemoryStream } from 'xstream'; | ||
export declare type Pathname = string; | ||
export declare type Search = string; | ||
export declare type Hash = string; | ||
export declare type LocationKey = string; | ||
export declare type HistoryDriver = Driver<Stream<HistoryInput>, MemoryStream<Location>>; | ||
export declare type PushHistoryInput = { | ||
type: 'push'; | ||
pathname: Pathname; | ||
pathname?: Pathname; | ||
search?: Search; | ||
state?: any; | ||
hash?: Hash; | ||
key?: LocationKey; | ||
}; | ||
@@ -12,0 +18,0 @@ export declare type ReplaceHistoryInput = { |
@@ -0,1 +1,12 @@ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
import xs from 'xstream'; | ||
@@ -18,3 +29,3 @@ export function createHistory$(history, sink$) { | ||
if (input.type === 'push') { | ||
history.push(input.pathname, input.state); | ||
history.push(__assign({}, input)); | ||
} | ||
@@ -21,0 +32,0 @@ if (input.type === 'replace') { |
@@ -5,7 +5,13 @@ import { Stream, MemoryStream } from 'xstream'; | ||
export declare type Pathname = string; | ||
export declare type Search = string; | ||
export declare type Hash = string; | ||
export declare type LocationKey = string; | ||
export declare type HistoryDriver = Driver<Stream<HistoryInput>, MemoryStream<Location>>; | ||
export declare type PushHistoryInput = { | ||
type: 'push'; | ||
pathname: Pathname; | ||
pathname?: Pathname; | ||
search?: Search; | ||
state?: any; | ||
hash?: Hash; | ||
key?: LocationKey; | ||
}; | ||
@@ -12,0 +18,0 @@ export declare type ReplaceHistoryInput = { |
{ | ||
"name": "@cycle/history", | ||
"version": "7.1.0", | ||
"version": "7.2.0", | ||
"description": "The standard history driver for Cycle.js", | ||
@@ -53,6 +53,6 @@ "main": "lib/cjs/index.js", | ||
"test": "pnpm run test-node && pnpm run test-browser", | ||
"test-ci": "CI=true pnpm test", | ||
"test-ci": "CI=true ../.scripts/retry.sh pnpm test", | ||
"test-live": "LIVE=true pnpm test", | ||
"prepublishOnly": "pnpm run build && pnpm run test" | ||
"prepublishOnly": "pnpm run build && pnpm test" | ||
} | ||
} |
@@ -27,3 +27,3 @@ import xs, {Stream, MemoryStream, Listener} from 'xstream'; | ||
if (input.type === 'push') { | ||
history.push(input.pathname, input.state); | ||
history.push({...input}); | ||
} | ||
@@ -30,0 +30,0 @@ |
@@ -5,2 +5,5 @@ import {Stream, MemoryStream} from 'xstream'; | ||
export type Pathname = string; | ||
export type Search = string; | ||
export type Hash = string; | ||
export type LocationKey = string; | ||
@@ -14,4 +17,7 @@ export type HistoryDriver = Driver< | ||
type: 'push'; | ||
pathname: Pathname; | ||
pathname?: Pathname; | ||
search?: Search; | ||
state?: any; | ||
hash?: Hash; | ||
key?: LocationKey; | ||
}; | ||
@@ -18,0 +24,0 @@ |
@@ -86,2 +86,24 @@ import * as assert from 'assert'; | ||
it('should allow changing search with PushHistoryInput', function(done) { | ||
function main(_sources: {history: Observable<Location>}) { | ||
return { | ||
history: of<PushHistoryInput>({type: 'push', search: '?a=b'}), | ||
}; | ||
} | ||
const {sources, run} = setup(main, {history: makeHistoryDriver()}); | ||
sources.history.pipe(skip(1)).subscribe({ | ||
next(location: Location) { | ||
assert.strictEqual(location.search, '?a=b'); | ||
done(); | ||
}, | ||
error: done, | ||
complete: () => { | ||
done('complete should not be called'); | ||
}, | ||
}); | ||
dispose = run(); | ||
}); | ||
it('should create a location from ReplaceHistoryInput', function(done) { | ||
@@ -88,0 +110,0 @@ function main(_sources: {history: Observable<Location>}) { |
@@ -85,2 +85,24 @@ import * as assert from 'assert'; | ||
it('should allow changing search with PushHistoryInput', function(done) { | ||
function main(_sources: {history: Stream<Location>}) { | ||
return { | ||
history: xs.of<PushHistoryInput>({type: 'push', search: '?a=b'}), | ||
}; | ||
} | ||
const {sources, run} = setup(main, {history: makeHistoryDriver()}); | ||
sources.history.drop(1).subscribe({ | ||
next(location: Location) { | ||
assert.strictEqual(location.search, '?a=b'); | ||
done(); | ||
}, | ||
error: done, | ||
complete: () => { | ||
done('complete should not be called'); | ||
}, | ||
}); | ||
dispose = run(); | ||
}); | ||
it('should create a location from ReplaceHistoryInput', function(done) { | ||
@@ -87,0 +109,0 @@ function main(_sources: {history: Stream<Location>}) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2049
87023
47