mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
parent
579970f8b7
commit
47b7924a7d
@ -252,19 +252,20 @@ function CombiningMultipleStreamsAndProperties() {
|
||||
|
||||
{
|
||||
// To calculate the current sum of three numeric Properties, you can do:
|
||||
var property = Bacon.constant(1),
|
||||
stream = Bacon.once(2),
|
||||
// (NOTE: combineWith requires the first type argument to be ErrorEvent, but the constant
|
||||
// and once methods default to unknown, so we're forced to manually specify it)
|
||||
let property = Bacon.constant<ErrorEvent, number>(1),
|
||||
stream = Bacon.once<ErrorEvent, number>(2),
|
||||
constant = 3;
|
||||
// NOTE: had to explicitly specify the typing for `x:number, y:number, z:number`
|
||||
Bacon.combineWith((x:number, y:number, z:number) => x + y + z, property, stream, constant);
|
||||
Bacon.combineWith((x, y, z) => x + y + z, property, stream, constant);
|
||||
}
|
||||
|
||||
{
|
||||
// Assuming you've got streams or properties named `password`, `username`, `firstname` and `lastname`, you can do:
|
||||
var password = Bacon.constant("easy"),
|
||||
username = Bacon.constant("juha"),
|
||||
firstname = Bacon.constant("juha"),
|
||||
lastname = Bacon.constant("paananen"),
|
||||
let password = Bacon.constant<ErrorEvent, string>("easy"),
|
||||
username = Bacon.constant<ErrorEvent, string>("juha"),
|
||||
firstname = Bacon.constant<ErrorEvent, string>("juha"),
|
||||
lastname = Bacon.constant<ErrorEvent, string>("paananen"),
|
||||
// NOTE: you should provide `combineTemplate` typing explicitly!
|
||||
loginInfo = Bacon.combineTemplate<string, {
|
||||
magicNumber:number; userid:string; passwd:string;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user