Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ahejlsberg authored Jul 29, 2019
1 parent 579970f commit 47b7924
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions types/baconjs/baconjs-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 47b7924

Please sign in to comment.