rx.all.d.ts 337 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975
  1. declare module Rx {
  2. // Type alias for observables and promises
  3. export type ObservableOrPromise<T> = IObservable<T> | Observable<T> | Promise<T>;
  4. export type ArrayLike<T> = Array<T> | { length: number;[index: number]: T; };
  5. // Type alias for arrays and array like objects
  6. export type ArrayOrIterable<T> = ArrayLike<T>;
  7. /**
  8. * Promise A+
  9. */
  10. export interface Promise<T> {
  11. then<R>(onFulfilled: (value: T) => R|Promise<R>, onRejected: (error: any) => Promise<R>): Promise<R>;
  12. then<R>(onFulfilled: (value: T) => R|Promise<R>, onRejected?: (error: any) => R): Promise<R>;
  13. }
  14. /**
  15. * Promise A+
  16. */
  17. export interface IPromise<T> extends Promise<T> { }
  18. /**
  19. * Represents a push-style collection.
  20. */
  21. export interface IObservable<T> { }
  22. /**
  23. * Represents a push-style collection.
  24. */
  25. export interface Observable<T> extends IObservable<T> { }
  26. export module internals {
  27. export interface EmptyError extends Error { message: string; }
  28. export interface EmptyErrorStatic { new (): EmptyError; }
  29. export interface ObjectDisposedError extends Error { message: string; }
  30. export interface ObjectDisposedErrorStatic { new (): ObjectDisposedError; }
  31. export interface ArgumentOutOfRangeError extends Error { message: string; }
  32. export interface ArgumentOutOfRangeErrorStatic { new (): ArgumentOutOfRangeError; }
  33. export interface NotSupportedError extends Error { message: string; }
  34. export interface NotSupportedErrorStatic { new (): NotSupportedError; }
  35. export interface NotImplementedError extends Error { message: string; }
  36. export interface NotImplementedErrorStatic { new (): NotImplementedError; }
  37. }
  38. export module helpers {
  39. export var notImplemented: () => internals.NotImplementedError;
  40. export var notSupported: () => internals.NotSupportedError;
  41. }
  42. export module internals {
  43. export var bindCallback: (func: Function, thisArg: any, argCount: number) => Function;
  44. }
  45. export module internals {
  46. export var isEqual : (left: any, right: any) => boolean;
  47. }
  48. export interface IDisposable {
  49. dispose(): void;
  50. }
  51. export interface Disposable extends IDisposable {
  52. /** Is this value disposed. */
  53. isDisposed?: boolean;
  54. }
  55. interface DisposableStatic {
  56. /**
  57. * Provides a set of static methods for creating Disposables.
  58. * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.
  59. */
  60. new (action: () => void): Disposable;
  61. /**
  62. * Creates a disposable object that invokes the specified action when disposed.
  63. * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.
  64. * @return {Disposable} The disposable object that runs the given action upon disposal.
  65. */
  66. create(action: () => void): Disposable;
  67. /**
  68. * Gets the disposable that does nothing when disposed.
  69. */
  70. empty: IDisposable;
  71. /**
  72. * Validates whether the given object is a disposable
  73. * @param {Object} Object to test whether it has a dispose method
  74. * @returns {Boolean} true if a disposable object, else false.
  75. */
  76. isDisposable(d: any): boolean;
  77. }
  78. /**
  79. * Provides a set of static methods for creating Disposables.
  80. * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.
  81. */
  82. export var Disposable: DisposableStatic;
  83. export module config {
  84. export var Promise: { new <T>(resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise<T>; };
  85. }
  86. export module helpers {
  87. export var noop: () => void;
  88. export var notDefined: (value: any) => boolean;
  89. export var identity: <T>(value: T) => T;
  90. export var defaultNow: () => number;
  91. export var defaultComparer: (left: any, right: any) => boolean;
  92. export var defaultSubComparer: (left: any, right: any) => number;
  93. export var defaultKeySerializer: (key: any) => string;
  94. export var defaultError: (err: any) => void;
  95. export var isPromise: (p: any) => boolean;
  96. export var asArray: <T>(...args: T[]) => T[];
  97. export var not: (value: any) => boolean;
  98. export var isFunction: (value: any) => boolean;
  99. }
  100. export type _Selector<T, TResult> = (value: T, index: number, observable: Observable<T>) => TResult;
  101. export type _ValueOrSelector<T, TResult> = TResult | _Selector<T, TResult>;
  102. export type _Predicate<T> = _Selector<T, boolean>;
  103. export type _Comparer<T, TResult> = (value1: T, value2: T) => TResult;
  104. export type _Accumulator<T, TAcc> = (acc: TAcc, value: T) => TAcc;
  105. export module special {
  106. export type _FlatMapResultSelector<T1, T2, TResult> = (value: T1, selectorValue: T2, index: number, selectorOther: number) => TResult;
  107. }
  108. export interface IObservable<T> {
  109. /**
  110. * Subscribes an o to the observable sequence.
  111. * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.
  112. * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.
  113. * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.
  114. * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions.
  115. */
  116. subscribe(observer: IObserver<T>): IDisposable;
  117. /**
  118. * Subscribes an o to the observable sequence.
  119. * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.
  120. * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.
  121. * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.
  122. * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions.
  123. */
  124. subscribe(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable;
  125. }
  126. export interface Observable<T> {
  127. /**
  128. * Subscribes an o to the observable sequence.
  129. * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.
  130. * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.
  131. * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.
  132. * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions.
  133. */
  134. subscribe(observer: IObserver<T>): IDisposable;
  135. /**
  136. * Subscribes an o to the observable sequence.
  137. * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.
  138. * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.
  139. * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.
  140. * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions.
  141. */
  142. subscribe(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable;
  143. /**
  144. * Subscribes to the next value in the sequence with an optional "this" argument.
  145. * @param {Function} onNext The function to invoke on each element in the observable sequence.
  146. * @param {Any} [thisArg] Object to use as this when executing callback.
  147. * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.
  148. */
  149. subscribeOnNext(onNext: (value: T) => void, thisArg?: any): IDisposable;
  150. /**
  151. * Subscribes to an exceptional condition in the sequence with an optional "this" argument.
  152. * @param {Function} onError The function to invoke upon exceptional termination of the observable sequence.
  153. * @param {Any} [thisArg] Object to use as this when executing callback.
  154. * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.
  155. */
  156. subscribeOnError(onError: (exception: any) => void, thisArg?: any): IDisposable;
  157. /**
  158. * Subscribes to the next value in the sequence with an optional "this" argument.
  159. * @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence.
  160. * @param {Any} [thisArg] Object to use as this when executing callback.
  161. * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.
  162. */
  163. subscribeOnCompleted(onCompleted: () => void, thisArg?: any): IDisposable;
  164. /**
  165. * Subscribes an o to the observable sequence.
  166. * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.
  167. * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.
  168. * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.
  169. * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions.
  170. */
  171. forEach(observer: IObserver<T>): IDisposable;
  172. /**
  173. * Subscribes an o to the observable sequence.
  174. * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.
  175. * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.
  176. * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.
  177. * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions.
  178. */
  179. forEach(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable;
  180. }
  181. export interface ObservableStatic {
  182. /**
  183. * Determines whether the given object is an Observable
  184. * @param {Any} An object to determine whether it is an Observable
  185. * @returns {Boolean} true if an Observable, else false.
  186. */
  187. isObservable(o: any): boolean;
  188. }
  189. export var Observable: ObservableStatic;
  190. export module internals {
  191. export var inherits: (child: any, parent: any) => void;
  192. export var addProperties: (obj: any, ...sources: any[]) => void;
  193. export var addRef: <T>(xs: Observable<T>, r: { getDisposable(): IDisposable; }) => Observable<T>;
  194. }
  195. export module internals {
  196. export interface ScheduledItem<TTime> {
  197. scheduler: IScheduler;
  198. state: TTime;
  199. action: (scheduler: IScheduler, state: any) => IDisposable;
  200. dueTime: TTime;
  201. comparer: (x: TTime, y: TTime) => number;
  202. disposable: SingleAssignmentDisposable;
  203. invoke(): void;
  204. compareTo(other: ScheduledItem<TTime>): number;
  205. isCancelled(): boolean;
  206. invokeCore(): IDisposable;
  207. }
  208. interface ScheduledItemStatic {
  209. new <TTime>(scheduler: IScheduler, state: any, action: (scheduler: IScheduler, state: any) => IDisposable, dueTime: TTime, comparer?: _Comparer<TTime, number>):ScheduledItem<TTime>;
  210. }
  211. export var ScheduledItem: ScheduledItemStatic
  212. }
  213. export module internals {
  214. // Priority Queue for Scheduling
  215. export interface PriorityQueue<TTime> {
  216. length: number;
  217. isHigherPriority(left: number, right: number): boolean;
  218. percolate(index: number): void;
  219. heapify(index: number): void;
  220. peek(): ScheduledItem<TTime>;
  221. removeAt(index: number): void;
  222. dequeue(): ScheduledItem<TTime>;
  223. enqueue(item: ScheduledItem<TTime>): void;
  224. remove(item: ScheduledItem<TTime>): boolean;
  225. }
  226. interface PriorityQueueStatic {
  227. new <T>(capacity: number) : PriorityQueue<T>;
  228. count: number;
  229. }
  230. export var PriorityQueue : PriorityQueueStatic;
  231. }
  232. /**
  233. * Represents a group of disposable resources that are disposed together.
  234. * @constructor
  235. */
  236. export interface CompositeDisposable extends Disposable {
  237. /**
  238. * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.
  239. * @param {Mixed} item Disposable to add.
  240. */
  241. add(item: IDisposable): void;
  242. /**
  243. * Removes and disposes the first occurrence of a disposable from the CompositeDisposable.
  244. * @param {Mixed} item Disposable to remove.
  245. * @returns {Boolean} true if found; false otherwise.
  246. */
  247. remove(item: IDisposable): void;
  248. }
  249. interface CompositeDisposableStatic {
  250. /**
  251. * Represents a group of disposable resources that are disposed together.
  252. * @constructor
  253. */
  254. new (...disposables: Rx.IDisposable[]): CompositeDisposable;
  255. /**
  256. * Represents a group of disposable resources that are disposed together.
  257. * @constructor
  258. */
  259. new(disposables: Rx.IDisposable[]): CompositeDisposable;
  260. }
  261. export var CompositeDisposable: CompositeDisposableStatic;
  262. export interface SingleAssignmentDisposable {
  263. /** Performs the task of cleaning up resources. */
  264. dispose(): void;
  265. /** Is this value disposed. */
  266. isDisposed: boolean;
  267. getDisposable(): IDisposable;
  268. setDisposable(value: IDisposable): void;
  269. }
  270. interface SingleAssignmentDisposableStatic {
  271. new() : SingleAssignmentDisposable;
  272. }
  273. export var SingleAssignmentDisposable : SingleAssignmentDisposableStatic;
  274. export interface SerialDisposable {
  275. /** Performs the task of cleaning up resources. */
  276. dispose(): void;
  277. /** Is this value disposed. */
  278. isDisposed: boolean;
  279. getDisposable(): IDisposable;
  280. setDisposable(value: IDisposable): void;
  281. }
  282. interface SerialDisposableStatic {
  283. new() : SerialDisposable;
  284. }
  285. export var SerialDisposable : SerialDisposableStatic;
  286. /**
  287. * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.
  288. */
  289. export interface RefCountDisposable extends Disposable {
  290. /** Performs the task of cleaning up resources. */
  291. dispose(): void;
  292. /** Is this value disposed. */
  293. isDisposed: boolean;
  294. /**
  295. * Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable.
  296. * @returns {Disposable} A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime.
  297. */
  298. getDisposable(): IDisposable;
  299. }
  300. interface RefCountDisposableStatic {
  301. /**
  302. * Initializes a new instance of the RefCountDisposable with the specified disposable.
  303. * @constructor
  304. * @param {Disposable} disposable Underlying disposable.
  305. */
  306. new(disposable: IDisposable): RefCountDisposable;
  307. }
  308. export var RefCountDisposable : RefCountDisposableStatic;
  309. export interface IScheduler {
  310. /** Gets the current time according to the local machine's system clock. */
  311. now(): number;
  312. /**
  313. * Schedules an action to be executed.
  314. * @param state State passed to the action to be executed.
  315. * @param {Function} action Action to be executed.
  316. * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
  317. */
  318. schedule<TState>(state: TState, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable;
  319. /**
  320. * Schedules an action to be executed after dueTime.
  321. * @param state State passed to the action to be executed.
  322. * @param {Function} action Action to be executed.
  323. * @param {Number} dueTime Relative time after which to execute the action.
  324. * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
  325. */
  326. scheduleFuture<TState>(state: TState, dueTime: number | Date, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable;
  327. }
  328. export interface SchedulerStatic {
  329. /** Gets the current time according to the local machine's system clock. */
  330. now(): number;
  331. /**
  332. * Normalizes the specified TimeSpan value to a positive value.
  333. * @param {Number} timeSpan The time span value to normalize.
  334. * @returns {Number} The specified TimeSpan value if it is zero or positive; otherwise, 0
  335. */
  336. normalize(timeSpan: number): number;
  337. /** Determines whether the given object is a scheduler */
  338. isScheduler(s: any): boolean;
  339. }
  340. /** Provides a set of static properties to access commonly used schedulers. */
  341. export var Scheduler: SchedulerStatic;
  342. export interface IScheduler {
  343. /**
  344. * Schedules an action to be executed recursively.
  345. * @param {Mixed} state State passed to the action to be executed.
  346. * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state.
  347. * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
  348. */
  349. scheduleRecursive<TState>(state: TState, action: (state: TState, action: (state: TState) => void) => void): IDisposable;
  350. /**
  351. * Schedules an action to be executed recursively after a specified relative due time.
  352. * @param {Mixed} state State passed to the action to be executed.
  353. * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state.
  354. * @param {Number}dueTime Relative time after which to execute the action for the first time.
  355. * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
  356. */
  357. scheduleRecursiveFuture<TState, TTime extends number | Date>(state: TState, dueTime: TTime, action: (state: TState, action: (state: TState, dueTime: TTime) => void) => void): IDisposable;
  358. }
  359. export interface IScheduler {
  360. /**
  361. * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.
  362. * @param {Mixed} state Initial state passed to the action upon the first iteration.
  363. * @param {Number} period Period for running the work periodically.
  364. * @param {Function} action Action to be executed, potentially updating the state.
  365. * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).
  366. */
  367. schedulePeriodic<TState>(state: TState, period: number, action: (state: TState) => TState): IDisposable;
  368. }
  369. export interface IScheduler {
  370. /**
  371. * Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions.
  372. * @param {Function} handler Handler that's run if an exception is caught. The exception will be rethrown if the handler returns false.
  373. * @returns {Scheduler} Wrapper around the original scheduler, enforcing exception handling.
  374. */
  375. catch(handler: Function): IScheduler;
  376. }
  377. export module internals {
  378. export interface SchedulePeriodicRecursive {
  379. start(): IDisposable;
  380. }
  381. interface SchedulePeriodicRecursiveStatic {
  382. new (scheduler: any, state: any, period: any, action: any) : SchedulePeriodicRecursive;
  383. }
  384. export var SchedulePeriodicRecursive: SchedulePeriodicRecursiveStatic;
  385. }
  386. export interface SchedulerStatic {
  387. immediate: IScheduler;
  388. }
  389. export interface ICurrentThreadScheduler extends IScheduler {
  390. scheduleRequired(): boolean;
  391. }
  392. export interface SchedulerStatic {
  393. currentThread: ICurrentThreadScheduler;
  394. }
  395. export interface SchedulerStatic {
  396. default: IScheduler;
  397. async: IScheduler;
  398. }
  399. /**
  400. * Supports push-style iteration over an observable sequence.
  401. */
  402. export interface IObserver<T> {
  403. /**
  404. * Notifies the observer of a new element in the sequence.
  405. * @param {Any} value Next element in the sequence.
  406. */
  407. onNext(value: T): void;
  408. /**
  409. * Notifies the observer that an exception has occurred.
  410. * @param {Any} error The error that has occurred.
  411. */
  412. onError(exception: any): void;
  413. /**
  414. * Notifies the observer of the end of the sequence.
  415. */
  416. onCompleted(): void;
  417. }
  418. export interface Observer<T> {
  419. /**
  420. * Notifies the observer of a new element in the sequence.
  421. * @param {Any} value Next element in the sequence.
  422. */
  423. onNext(value: T): void;
  424. /**
  425. * Notifies the observer that an exception has occurred.
  426. * @param {Any} error The error that has occurred.
  427. */
  428. onError(exception: any): void;
  429. /**
  430. * Notifies the observer of the end of the sequence.
  431. */
  432. onCompleted(): void;
  433. }
  434. export interface ObserverStatic {
  435. /**
  436. * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions.
  437. * @param {Function} [onNext] Observer's OnNext action implementation.
  438. * @param {Function} [onError] Observer's OnError action implementation.
  439. * @param {Function} [onCompleted] Observer's OnCompleted action implementation.
  440. * @returns {Observer} The observer object implemented using the given actions.
  441. */
  442. create<T>(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observer<T>;
  443. }
  444. /**
  445. * Supports push-style iteration over an observable sequence.
  446. */
  447. export var Observer: ObserverStatic;
  448. /**
  449. * Represents a notification to an observer.
  450. */
  451. export interface Notification<T> {
  452. /**
  453. * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result.
  454. *
  455. * @memberOf Notification
  456. * @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on..
  457. * @param {Function} onError Delegate to invoke for an OnError notification.
  458. * @param {Function} onCompleted Delegate to invoke for an OnCompleted notification.
  459. * @returns {Any} Result produced by the observation.
  460. */
  461. accept(observer: IObserver<T>): void;
  462. /**
  463. * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result.
  464. *
  465. * @memberOf Notification
  466. * @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on..
  467. * @param {Function} onError Delegate to invoke for an OnError notification.
  468. * @param {Function} onCompleted Delegate to invoke for an OnCompleted notification.
  469. * @returns {Any} Result produced by the observation.
  470. */
  471. accept<TResult>(onNext: (value: T) => TResult, onError: (exception: any) => TResult, onCompleted: () => TResult): TResult;
  472. /**
  473. * Returns an observable sequence with a single notification.
  474. *
  475. * @memberOf Notifications
  476. * @param {Scheduler} [scheduler] Scheduler to send out the notification calls on.
  477. * @returns {Observable} The observable sequence that surfaces the behavior of the notification upon subscription.
  478. */
  479. toObservable(scheduler?: IScheduler): Observable<T>;
  480. hasValue: boolean;
  481. equals(other: Notification<T>): boolean;
  482. kind: string;
  483. value: T;
  484. error: any;
  485. }
  486. interface NotificationStatic {
  487. new <T>(kind: any, value: any, exception: any, accept: any, acceptObservable: any, toString: any) : Notification<T>;
  488. /**
  489. * Creates an object that represents an OnNext notification to an observer.
  490. * @param {Any} value The value contained in the notification.
  491. * @returns {Notification} The OnNext notification containing the value.
  492. */
  493. createOnNext<T>(value: T): Notification<T>;
  494. /**
  495. * Creates an object that represents an OnError notification to an observer.
  496. * @param {Any} error The exception contained in the notification.
  497. * @returns {Notification} The OnError notification containing the exception.
  498. */
  499. createOnError<T>(exception: any): Notification<T>;
  500. /**
  501. * Creates an object that represents an OnCompleted notification to an observer.
  502. * @returns {Notification} The OnCompleted notification.
  503. */
  504. createOnCompleted<T>(): Notification<T>;
  505. }
  506. export var Notification : NotificationStatic;
  507. export interface Observer<T> {
  508. makeSafe(disposable: IDisposable): Observer<T>;
  509. }
  510. export module internals {
  511. /**
  512. * Abstract base class for implementations of the Observer class.
  513. * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages.
  514. */
  515. export interface AbstractObserver<T> extends Rx.IObserver<T>, Rx.IDisposable {
  516. /**
  517. * Notifies the observer of a new element in the sequence.
  518. * @param {Any} value Next element in the sequence.
  519. */
  520. onNext(value: T): void;
  521. /**
  522. * Notifies the observer that an exception has occurred.
  523. * @param {Any} error The error that has occurred.
  524. */
  525. onError(exception: any): void;
  526. /**
  527. * Notifies the observer of the end of the sequence.
  528. */
  529. onCompleted(): void;
  530. isStopped: boolean;
  531. /**
  532. * Disposes the observer, causing it to transition to the stopped state.
  533. */
  534. dispose(): void;
  535. fail(e: any): boolean;
  536. // Must be implemented by other observers
  537. next(value: T): void;
  538. error(error: any): void;
  539. completed(): void;
  540. }
  541. interface AbstractObserverStatic {
  542. new <T>(): AbstractObserver<T>;
  543. }
  544. export var AbstractObserver: AbstractObserverStatic
  545. }
  546. /**
  547. * Class to create an Observer instance from delegate-based implementations of the on* methods.
  548. */
  549. export interface AnonymousObserver<T> extends Observer<T> {
  550. /**
  551. * Notifies the observer of a new element in the sequence.
  552. * @param {Any} value Next element in the sequence.
  553. */
  554. onNext(value: T): void;
  555. /**
  556. * Notifies the observer that an exception has occurred.
  557. * @param {Any} error The error that has occurred.
  558. */
  559. onError(exception: any): void;
  560. /**
  561. * Notifies the observer of the end of the sequence.
  562. */
  563. onCompleted(): void;
  564. }
  565. interface AnonymousObserverStatic {
  566. /**
  567. * Creates an observer from the specified OnNext, OnError, and OnCompleted actions.
  568. * @param {Any} onNext Observer's OnNext action implementation.
  569. * @param {Any} onError Observer's OnError action implementation.
  570. * @param {Any} onCompleted Observer's OnCompleted action implementation.
  571. */
  572. new <T>(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): AnonymousObserver<T>;
  573. }
  574. export var AnonymousObserver : AnonymousObserverStatic;
  575. export interface CheckedObserver<T> extends Observer<T> {
  576. checkAccess(): void;
  577. }
  578. export module internals {
  579. export interface ScheduledObserver<T> extends Observer<T> {
  580. ensureActive(): void;
  581. }
  582. }
  583. export interface Observable<T> {
  584. /**
  585. * Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
  586. *
  587. * This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
  588. * that require to be run on a scheduler, use subscribeOn.
  589. *
  590. * @param {Scheduler} scheduler Scheduler to notify observers on.
  591. * @returns {Observable} The source sequence whose observations happen on the specified scheduler.
  592. */
  593. observeOn(scheduler: IScheduler): Observable<T>;
  594. }
  595. export interface Observable<T> {
  596. /**
  597. * Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;
  598. * see the remarks section for more information on the distinction between subscribeOn and observeOn.
  599. * This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer
  600. * callbacks on a scheduler, use observeOn.
  601. * @param {Scheduler} scheduler Scheduler to perform subscription and unsubscription actions on.
  602. * @returns {Observable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.
  603. */
  604. subscribeOn(scheduler: IScheduler): Observable<T>;
  605. }
  606. export interface ObservableStatic {
  607. /**
  608. * Converts a Promise to an Observable sequence
  609. * @param {Promise} An ES6 Compliant promise.
  610. * @returns {Observable} An Observable sequence which wraps the existing promise success and failure.
  611. */
  612. fromPromise<T>(promise: Promise<T>): Observable<T>;
  613. }
  614. export interface Observable<T> {
  615. /*
  616. * Converts an existing observable sequence to an ES6 Compatible Promise
  617. * @example
  618. * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);
  619. *
  620. * // With config
  621. * Rx.config.Promise = RSVP.Promise;
  622. * var promise = Rx.Observable.return(42).toPromise();
  623. * @param {Function} [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise.
  624. * @returns {Promise} An ES6 compatible promise with the last value from the observable sequence.
  625. */
  626. toPromise(promiseCtor?: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise<T>; }): IPromise<T>;
  627. /*
  628. * Converts an existing observable sequence to an ES6 Compatible Promise
  629. * @example
  630. * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);
  631. *
  632. * // With config
  633. * Rx.config.Promise = RSVP.Promise;
  634. * var promise = Rx.Observable.return(42).toPromise();
  635. * @param {Function} [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise.
  636. * @returns {Promise} An ES6 compatible promise with the last value from the observable sequence.
  637. */
  638. toPromise<TPromise extends IPromise<T>>(promiseCtor: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): TPromise; }): TPromise;
  639. }
  640. export interface Observable<T> {
  641. /**
  642. * Creates an array from an observable sequence.
  643. * @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence.
  644. */
  645. toArray(): Observable<T[]>;
  646. }
  647. export interface ObservableStatic {
  648. /**
  649. * Creates an observable sequence from a specified subscribe method implementation.
  650. * @example
  651. * var res = Rx.Observable.create(function (observer) { return function () { } );
  652. * var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } );
  653. * var res = Rx.Observable.create(function (observer) { } );
  654. * @param {Function} subscribe Implementation of the resulting observable sequence's subscribe method, returning a function that will be wrapped in a Disposable.
  655. * @returns {Observable} The observable sequence with the specified implementation for the Subscribe method.
  656. */
  657. create<T>(subscribe: (observer: Observer<T>) => IDisposable | Function | void): Observable<T>;
  658. }
  659. export interface ObservableStatic {
  660. /**
  661. * Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.
  662. *
  663. * @example
  664. * var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); });
  665. * @param {Function} observableFactory Observable factory function to invoke for each observer that subscribes to the resulting sequence or Promise.
  666. * @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function.
  667. */
  668. defer<T>(observableFactory: () => ObservableOrPromise<T>): Observable<T>;
  669. }
  670. export interface ObservableStatic {
  671. /**
  672. * Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
  673. *
  674. * @example
  675. * var res = Rx.Observable.empty();
  676. * var res = Rx.Observable.empty(Rx.Scheduler.timeout);
  677. * @param {Scheduler} [scheduler] Scheduler to send the termination call on.
  678. * @returns {Observable} An observable sequence with no elements.
  679. */
  680. empty<T>(scheduler?: IScheduler): Observable<T>;
  681. }
  682. export interface ObservableStatic {
  683. /**
  684. * This method creates a new Observable sequence from an array-like or iterable object.
  685. * @param {Any} arrayLike An array-like or iterable object to convert to an Observable sequence.
  686. * @param {Function} [mapFn] Map function to call on every element of the array.
  687. * @param {Any} [thisArg] The context to use calling the mapFn if provided.
  688. * @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread.
  689. */
  690. from<T>(array: ArrayOrIterable<T>): Observable<T>;
  691. /**
  692. * This method creates a new Observable sequence from an array-like or iterable object.
  693. * @param {Any} arrayLike An array-like or iterable object to convert to an Observable sequence.
  694. * @param {Function} [mapFn] Map function to call on every element of the array.
  695. * @param {Any} [thisArg] The context to use calling the mapFn if provided.
  696. * @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread.
  697. */
  698. from<T, TResult>(array: ArrayOrIterable<T>, mapFn: (value: T, index: number) => TResult, thisArg?: any, scheduler?: IScheduler): Observable<TResult>;
  699. }
  700. export interface ObservableStatic {
  701. /**
  702. * Converts an array to an observable sequence, using an optional scheduler to enumerate the array.
  703. * @deprecated use Observable.from or Observable.of
  704. * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.
  705. * @returns {Observable} The observable sequence whose elements are pulled from the given enumerable sequence.
  706. */
  707. fromArray<T>(array: ArrayLike<T>, scheduler?: IScheduler): Observable<T>;
  708. }
  709. export interface ObservableStatic {
  710. /**
  711. * Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.
  712. *
  713. * @example
  714. * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; });
  715. * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }, Rx.Scheduler.timeout);
  716. * @param {Mixed} initialState Initial state.
  717. * @param {Function} condition Condition to terminate generation (upon returning false).
  718. * @param {Function} iterate Iteration step function.
  719. * @param {Function} resultSelector Selector function for results produced in the sequence.
  720. * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not provided, defaults to Scheduler.currentThread.
  721. * @returns {Observable} The generated sequence.
  722. */
  723. generate<TState, TResult>(initialState: TState, condition: (state: TState) => boolean, iterate: (state: TState) => TState, resultSelector: (state: TState) => TResult, scheduler?: IScheduler): Observable<TResult>;
  724. }
  725. export interface ObservableStatic {
  726. /**
  727. * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
  728. * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.
  729. */
  730. of<T>(...values: T[]): Observable<T>;
  731. /**
  732. * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
  733. * @param {Scheduler} scheduler A scheduler to use for scheduling the arguments.
  734. * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.
  735. */
  736. ofWithScheduler<T>(scheduler?: IScheduler, ...values: T[]): Observable<T>;
  737. }
  738. export interface ArrayObserveChange<T> {
  739. type: string;
  740. object: T[];
  741. name?: string;
  742. oldValue?: T;
  743. index?: number;
  744. removed?: T[];
  745. added?: number;
  746. }
  747. export interface ObservableStatic {
  748. /**
  749. * Creates an Observable sequence from changes to an array using Array.observe.
  750. * @param {Array} array An array to observe changes.
  751. * @returns {Observable} An observable sequence containing changes to an array from Array.observe.
  752. */
  753. ofArrayChanges<T>(obj: T[]): Observable<ArrayObserveChange<T>>;
  754. }
  755. export interface ObjectObserveChange<T> {
  756. type: string;
  757. object: T;
  758. name: string;
  759. oldValue?: any;
  760. }
  761. export interface ObservableStatic {
  762. /**
  763. * Creates an Observable sequence from changes to an object using Object.observe.
  764. * @param {Object} obj An object to observe changes.
  765. * @returns {Observable} An observable sequence containing changes to an object from Object.observe.
  766. */
  767. ofObjectChanges<T>(obj: T): Observable<ObjectObserveChange<T>>;
  768. }
  769. export interface ObservableStatic {
  770. /**
  771. * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  772. * @returns {Observable} An observable sequence whose observers will never get called.
  773. */
  774. never<T>(): Observable<T>;
  775. }
  776. export interface ObservableStatic {
  777. /**
  778. * Convert an object into an observable sequence of [key, value] pairs.
  779. * @param {Object} obj The object to inspect.
  780. * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.
  781. * @returns {Observable} An observable sequence of [key, value] pairs from the object.
  782. */
  783. pairs<T>(obj: { [key: string]: T }, scheduler?: IScheduler): Observable<[string, T]>;
  784. /**
  785. * Convert an object into an observable sequence of [key, value] pairs.
  786. * @param {Object} obj The object to inspect.
  787. * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.
  788. * @returns {Observable} An observable sequence of [key, value] pairs from the object.
  789. */
  790. pairs<T>(obj: { [key: number]: T }, scheduler?: IScheduler): Observable<[number, T]>;
  791. }
  792. export interface ObservableStatic {
  793. /**
  794. * Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.
  795. *
  796. * @example
  797. * var res = Rx.Observable.range(0, 10);
  798. * var res = Rx.Observable.range(0, 10, Rx.Scheduler.timeout);
  799. * @param {Number} start The value of the first integer in the sequence.
  800. * @param {Number} count The number of sequential integers to generate.
  801. * @param {Scheduler} [scheduler] Scheduler to run the generator loop on. If not specified, defaults to Scheduler.currentThread.
  802. * @returns {Observable} An observable sequence that contains a range of sequential integral numbers.
  803. */
  804. range(start: number, count: number, scheduler?: IScheduler): Observable<number>;
  805. }
  806. export interface ObservableStatic {
  807. /**
  808. * Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.
  809. *
  810. * @example
  811. * var res = Rx.Observable.repeat(42);
  812. * var res = Rx.Observable.repeat(42, 4);
  813. * 3 - res = Rx.Observable.repeat(42, 4, Rx.Scheduler.timeout);
  814. * 4 - res = Rx.Observable.repeat(42, null, Rx.Scheduler.timeout);
  815. * @param {Mixed} value Element to repeat.
  816. * @param {Number} repeatCount [Optiona] Number of times to repeat the element. If not specified, repeats indefinitely.
  817. * @param {Scheduler} scheduler Scheduler to run the producer loop on. If not specified, defaults to Scheduler.immediate.
  818. * @returns {Observable} An observable sequence that repeats the given element the specified number of times.
  819. */
  820. repeat<T>(value: T, repeatCount?: number | void, scheduler?: IScheduler): Observable<T>;
  821. }
  822. export interface ObservableStatic {
  823. /**
  824. * Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
  825. * There is an alias called 'just' or browsers <IE9.
  826. * @param {Mixed} value Single element in the resulting observable sequence.
  827. * @param {Scheduler} scheduler Scheduler to send the single element on. If not specified, defaults to Scheduler.immediate.
  828. * @returns {Observable} An observable sequence containing the single specified element.
  829. */
  830. return<T>(value: T, scheduler?: IScheduler): Observable<T>;
  831. /**
  832. * Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
  833. * There is an alias called 'just' or browsers <IE9.
  834. * @param {Mixed} value Single element in the resulting observable sequence.
  835. * @param {Scheduler} scheduler Scheduler to send the single element on. If not specified, defaults to Scheduler.immediate.
  836. * @returns {Observable} An observable sequence containing the single specified element.
  837. */
  838. just<T>(value: T, scheduler?: IScheduler): Observable<T>;
  839. }
  840. export interface ObservableStatic {
  841. /**
  842. * Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single onError message.
  843. * @param {Mixed} error An object used for the sequence's termination.
  844. * @param {Scheduler} scheduler Scheduler to send the exceptional termination call on. If not specified, defaults to Scheduler.immediate.
  845. * @returns {Observable} The observable sequence that terminates exceptionally with the specified exception object.
  846. */
  847. throw<T>(exception: Error, scheduler?: IScheduler): Observable<T>;
  848. /**
  849. * Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single onError message.
  850. * @param {Mixed} error An object used for the sequence's termination.
  851. * @param {Scheduler} scheduler Scheduler to send the exceptional termination call on. If not specified, defaults to Scheduler.immediate.
  852. * @returns {Observable} The observable sequence that terminates exceptionally with the specified exception object.
  853. */
  854. throw<T>(exception: any, scheduler?: IScheduler): Observable<T>;
  855. }
  856. export interface ObservableStatic {
  857. /**
  858. * Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
  859. * @param {Function} resourceFactory Factory function to obtain a resource object.
  860. * @param {Function} observableFactory Factory function to obtain an observable sequence that depends on the obtained resource.
  861. * @returns {Observable} An observable sequence whose lifetime controls the lifetime of the dependent resource object.
  862. */
  863. using<TSource, TResource extends IDisposable>(resourceFactory: () => TResource, observableFactory: (resource: TResource) => Observable<TSource>): Observable<TSource>;
  864. }
  865. export interface Observable<T> {
  866. /**
  867. * Propagates the observable sequence or Promise that reacts first.
  868. * @param {Observable} rightSource Second observable sequence or Promise.
  869. * @returns {Observable} {Observable} An observable sequence that surfaces either of the given sequences, whichever reacted first.
  870. */
  871. amb(observable: ObservableOrPromise<T>): Observable<T>;
  872. }
  873. export interface ObservableStatic {
  874. /**
  875. * Propagates the observable sequence or Promise that reacts first.
  876. * @returns {Observable} An observable sequence that surfaces any of the given sequences, whichever reacted first.
  877. */
  878. amb<T>(observables: ObservableOrPromise<T>[]): Observable<T>;
  879. /**
  880. * Propagates the observable sequence or Promise that reacts first.
  881. * @returns {Observable} An observable sequence that surfaces any of the given sequences, whichever reacted first.
  882. */
  883. amb<T>(...observables: ObservableOrPromise<T>[]): Observable<T>;
  884. }
  885. export interface Observable<T> {
  886. /**
  887. * Continues an observable sequence that is terminated by an exception with the next observable sequence.
  888. * @param {Mixed} handlerOrSecond Exception handler function that returns an observable sequence given the error that occurred in the first sequence, or a second observable sequence used to produce results when an error occurred in the first sequence.
  889. * @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred.
  890. */
  891. catch(handler: (exception: any) => ObservableOrPromise<T>): Observable<T>;
  892. /**
  893. * Continues an observable sequence that is terminated by an exception with the next observable sequence.
  894. * @param {Mixed} handlerOrSecond Exception handler function that returns an observable sequence given the error that occurred in the first sequence, or a second observable sequence used to produce results when an error occurred in the first sequence.
  895. * @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred.
  896. */
  897. catch(second: ObservableOrPromise<T>): Observable<T>;
  898. }
  899. export interface ObservableStatic {
  900. /**
  901. * Continues an observable sequence that is terminated by an exception with the next observable sequence.
  902. * @param {Array | Arguments} args Arguments or an array to use as the next sequence if an error occurs.
  903. * @returns {Observable} An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.
  904. */
  905. catch<T>(sources: ObservableOrPromise<T>[]): Observable<T>;
  906. /**
  907. * Continues an observable sequence that is terminated by an exception with the next observable sequence.
  908. * @param {Array | Arguments} args Arguments or an array to use as the next sequence if an error occurs.
  909. * @returns {Observable} An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.
  910. */
  911. catch<T>(...sources: ObservableOrPromise<T>[]): Observable<T>;
  912. }
  913. export interface Observable<T> {
  914. /**
  915. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  916. * This can be in the form of an argument list of observables or an array.
  917. *
  918. * @example
  919. * 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  920. * 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  921. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  922. */
  923. combineLatest<T2, TResult>(second: ObservableOrPromise<T2>, resultSelector: (v1: T, v2: T2) => TResult): Observable<TResult>;
  924. /**
  925. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  926. * This can be in the form of an argument list of observables or an array.
  927. *
  928. * @example
  929. * 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  930. * 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  931. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  932. */
  933. combineLatest<T2, T3, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable<TResult>;
  934. /**
  935. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  936. * This can be in the form of an argument list of observables or an array.
  937. *
  938. * @example
  939. * 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  940. * 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  941. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  942. */
  943. combineLatest<T2, T3, T4, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable<TResult>;
  944. /**
  945. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  946. * This can be in the form of an argument list of observables or an array.
  947. *
  948. * @example
  949. * 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  950. * 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  951. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  952. */
  953. combineLatest<T2, T3, T4, T5, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable<TResult>;
  954. /**
  955. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  956. * This can be in the form of an argument list of observables or an array.
  957. *
  958. * @example
  959. * 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  960. * 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  961. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  962. */
  963. combineLatest<T2, T3, T4, T5, T6, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6) => TResult): Observable<TResult>;
  964. /**
  965. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  966. * This can be in the form of an argument list of observables or an array.
  967. *
  968. * @example
  969. * 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  970. * 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  971. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  972. */
  973. combineLatest<T2, T3, T4, T5, T6, T7, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, seventh: ObservableOrPromise<T7>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7) => TResult): Observable<TResult>;
  974. /**
  975. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  976. * This can be in the form of an argument list of observables or an array.
  977. *
  978. * @example
  979. * 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  980. * 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  981. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  982. */
  983. combineLatest<T2, T3, T4, T5, T6, T7, T8, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, seventh: ObservableOrPromise<T7>, eighth: ObservableOrPromise<T8>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8) => TResult): Observable<TResult>;
  984. /**
  985. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  986. * This can be in the form of an argument list of observables or an array.
  987. *
  988. * @example
  989. * 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  990. * 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  991. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  992. */
  993. combineLatest<T2, T3, T4, T5, T6, T7, T8, T9, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, seventh: ObservableOrPromise<T7>, eighth: ObservableOrPromise<T8>, ninth: ObservableOrPromise<T9>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9) => TResult): Observable<TResult>;
  994. /**
  995. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  996. * This can be in the form of an argument list of observables or an array.
  997. *
  998. * @example
  999. * 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  1000. * 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  1001. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1002. */
  1003. combineLatest<TOther, TResult>(souces: ObservableOrPromise<TOther>[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable<TResult>;
  1004. }
  1005. export interface ObservableStatic {
  1006. /**
  1007. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  1008. *
  1009. * @example
  1010. * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  1011. * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  1012. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1013. */
  1014. combineLatest<T, T2, TResult>(first: ObservableOrPromise<T>, second: ObservableOrPromise<T2>, resultSelector: (v1: T, v2: T2) => TResult): Observable<TResult>;
  1015. /**
  1016. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  1017. *
  1018. * @example
  1019. * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  1020. * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  1021. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1022. */
  1023. combineLatest<T, T2, T3, TResult>(first: ObservableOrPromise<T>, second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable<TResult>;
  1024. /**
  1025. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  1026. *
  1027. * @example
  1028. * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  1029. * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  1030. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1031. */
  1032. combineLatest<T, T2, T3, T4, TResult>(first: ObservableOrPromise<T>, second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable<TResult>;
  1033. /**
  1034. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  1035. *
  1036. * @example
  1037. * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  1038. * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  1039. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1040. */
  1041. combineLatest<T, T2, T3, T4, T5, TResult>(first: ObservableOrPromise<T>, second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable<TResult>;
  1042. /**
  1043. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  1044. *
  1045. * @example
  1046. * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  1047. * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  1048. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1049. */
  1050. combineLatest<T, T2, T3, T4, T5, T6, TResult>(first: ObservableOrPromise<T>, second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6) => TResult): Observable<TResult>;
  1051. /**
  1052. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  1053. *
  1054. * @example
  1055. * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  1056. * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  1057. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1058. */
  1059. combineLatest<T, T2, T3, T4, T5, T6, T7, TResult>(first: ObservableOrPromise<T>, second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, eventh: ObservableOrPromise<T7>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7) => TResult): Observable<TResult>;
  1060. /**
  1061. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  1062. *
  1063. * @example
  1064. * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  1065. * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  1066. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1067. */
  1068. combineLatest<T, T2, T3, T4, T5, T6, T7, T8, TResult>(first: ObservableOrPromise<T>, second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, seventh: ObservableOrPromise<T7>, eighth: ObservableOrPromise<T8>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8) => TResult): Observable<TResult>;
  1069. /**
  1070. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  1071. *
  1072. * @example
  1073. * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  1074. * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  1075. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1076. */
  1077. combineLatest<T, T2, T3, T4, T5, T6, T7, T8, T9, TResult>(first: ObservableOrPromise<T>, second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, seventh: ObservableOrPromise<T7>, eighth: ObservableOrPromise<T8>, ninth: ObservableOrPromise<T9>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9) => TResult): Observable<TResult>;
  1078. /**
  1079. * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
  1080. *
  1081. * @example
  1082. * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
  1083. * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
  1084. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1085. */
  1086. combineLatest<TOther, TResult>(souces: ObservableOrPromise<TOther>[], resultSelector: (...otherValues: TOther[]) => TResult): Observable<TResult>;
  1087. }
  1088. export interface Observable<T> {
  1089. /**
  1090. * Concatenates all the observable sequences. This takes in either an array or variable arguments to concatenate.
  1091. * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
  1092. */
  1093. concat(...sources: ObservableOrPromise<T>[]): Observable<T>;
  1094. }
  1095. export interface ObservableStatic {
  1096. /**
  1097. * Concatenates all the observable sequences.
  1098. * @param {Array | Arguments} args Arguments or an array to concat to the observable sequence.
  1099. * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
  1100. */
  1101. concat<T>(...sources: ObservableOrPromise<T>[]): Observable<T>;
  1102. /**
  1103. * Concatenates all the observable sequences.
  1104. * @param {Array | Arguments} args Arguments or an array to concat to the observable sequence.
  1105. * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
  1106. */
  1107. concat<T>(sources: ObservableOrPromise<T>[]): Observable<T>;
  1108. }
  1109. export interface Observable<T> {
  1110. /**
  1111. * Concatenates an observable sequence of observable sequences.
  1112. * @returns {Observable} An observable sequence that contains the elements of each observed inner sequence, in sequential order.
  1113. */
  1114. concatAll(): T;
  1115. }
  1116. export interface Observable<T> {
  1117. /**
  1118. * Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences.
  1119. * Or merges two observable sequences into a single observable sequence.
  1120. *
  1121. * @example
  1122. * 1 - merged = sources.merge(1);
  1123. * 2 - merged = source.merge(otherSource);
  1124. * @param {Mixed} [maxConcurrentOrOther] Maximum number of inner observable sequences being subscribed to concurrently or the second observable sequence.
  1125. * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
  1126. */
  1127. merge(maxConcurrent: number): T;
  1128. /**
  1129. * Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences.
  1130. * Or merges two observable sequences into a single observable sequence.
  1131. *
  1132. * @example
  1133. * 1 - merged = sources.merge(1);
  1134. * 2 - merged = source.merge(otherSource);
  1135. * @param {Mixed} [maxConcurrentOrOther] Maximum number of inner observable sequences being subscribed to concurrently or the second observable sequence.
  1136. * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
  1137. */
  1138. merge(other: ObservableOrPromise<T>): Observable<T>;
  1139. }
  1140. export interface ObservableStatic {
  1141. /**
  1142. * Merges all the observable sequences into a single observable sequence.
  1143. * The scheduler is optional and if not specified, the immediate scheduler is used.
  1144. * @returns {Observable} The observable sequence that merges the elements of the observable sequences.
  1145. */
  1146. merge<T>(...sources: ObservableOrPromise<T>[]): Observable<T>;
  1147. /**
  1148. * Merges all the observable sequences into a single observable sequence.
  1149. * The scheduler is optional and if not specified, the immediate scheduler is used.
  1150. * @returns {Observable} The observable sequence that merges the elements of the observable sequences.
  1151. */
  1152. merge<T>(sources: ObservableOrPromise<T>[]): Observable<T>;
  1153. /**
  1154. * Merges all the observable sequences into a single observable sequence.
  1155. * The scheduler is optional and if not specified, the immediate scheduler is used.
  1156. * @returns {Observable} The observable sequence that merges the elements of the observable sequences.
  1157. */
  1158. merge<T>(scheduler: IScheduler, ...sources: ObservableOrPromise<T>[]): Observable<T>;
  1159. /**
  1160. * Merges all the observable sequences into a single observable sequence.
  1161. * The scheduler is optional and if not specified, the immediate scheduler is used.
  1162. * @returns {Observable} The observable sequence that merges the elements of the observable sequences.
  1163. */
  1164. merge<T>(scheduler: IScheduler, sources: ObservableOrPromise<T>[]): Observable<T>;
  1165. }
  1166. export interface Observable<T> {
  1167. /**
  1168. * Merges an observable sequence of observable sequences into an observable sequence.
  1169. * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
  1170. */
  1171. mergeAll(): T;
  1172. }
  1173. export interface ObservableStatic {
  1174. /**
  1175. * Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to
  1176. * receive all successfully emitted items from all of the source Observables without being interrupted by
  1177. * an error notification from one of them.
  1178. *
  1179. * This behaves like Observable.prototype.mergeAll except that if any of the merged Observables notify of an
  1180. * error via the Observer's onError, mergeDelayError will refrain from propagating that
  1181. * error notification until all of the merged Observables have finished emitting items.
  1182. * @param {Array | Arguments} args Arguments or an array to merge.
  1183. * @returns {Observable} an Observable that emits all of the items emitted by the Observables emitted by the Observable
  1184. */
  1185. mergeDelayError<T>(...sources: ObservableOrPromise<T>[]): Observable<T>;
  1186. /**
  1187. * Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to
  1188. * receive all successfully emitted items from all of the source Observables without being interrupted by
  1189. * an error notification from one of them.
  1190. *
  1191. * This behaves like Observable.prototype.mergeAll except that if any of the merged Observables notify of an
  1192. * error via the Observer's onError, mergeDelayError will refrain from propagating that
  1193. * error notification until all of the merged Observables have finished emitting items.
  1194. * @param {Array | Arguments} args Arguments or an array to merge.
  1195. * @returns {Observable} an Observable that emits all of the items emitted by the Observables emitted by the Observable
  1196. */
  1197. mergeDelayError<T>(sources: ObservableOrPromise<T>[]): Observable<T>;
  1198. }
  1199. export interface Observable<T> {
  1200. /**
  1201. * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.
  1202. * @param {Observable} second Second observable sequence used to produce results after the first sequence terminates.
  1203. * @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.
  1204. */
  1205. onErrorResumeNext(second: ObservableOrPromise<T>): Observable<T>;
  1206. }
  1207. export interface ObservableStatic {
  1208. /**
  1209. * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.
  1210. *
  1211. * @example
  1212. * 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs);
  1213. * 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]);
  1214. * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.
  1215. */
  1216. onErrorResumeNext<T>(...sources: ObservableOrPromise<T>[]): Observable<T>;
  1217. /**
  1218. * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.
  1219. *
  1220. * @example
  1221. * 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs);
  1222. * 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]);
  1223. * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.
  1224. */
  1225. onErrorResumeNext<T>(sources: ObservableOrPromise<T>[]): Observable<T>;
  1226. }
  1227. export interface Observable<T> {
  1228. /**
  1229. * Returns the values from the source observable sequence only after the other observable sequence produces a value.
  1230. * @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence.
  1231. * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.
  1232. */
  1233. skipUntil<T2>(other: ObservableOrPromise<T2>): Observable<T>;
  1234. }
  1235. export interface Observable<T> {
  1236. /**
  1237. * Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
  1238. * @returns {Observable} The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received.
  1239. */
  1240. switch(): T;
  1241. /**
  1242. * Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
  1243. * @returns {Observable} The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received.
  1244. */
  1245. switchLatest(): T;
  1246. }
  1247. export interface Observable<T> {
  1248. /**
  1249. * Returns the values from the source observable sequence until the other observable sequence produces a value.
  1250. * @param {Observable | Promise} other Observable sequence or Promise that terminates propagation of elements of the source sequence.
  1251. * @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.
  1252. */
  1253. takeUntil<T2>(other: ObservableOrPromise<T2>): Observable<T>;
  1254. }
  1255. export interface Observable<T> {
  1256. /**
  1257. * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element.
  1258. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1259. */
  1260. withLatestFrom<T2, TResult>(second: ObservableOrPromise<T2>, resultSelector: (v1: T, v2: T2) => TResult): Observable<TResult>;
  1261. /**
  1262. * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element.
  1263. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1264. */
  1265. withLatestFrom<T2, T3, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable<TResult>;
  1266. /**
  1267. * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element.
  1268. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1269. */
  1270. withLatestFrom<T2, T3, T4, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable<TResult>;
  1271. /**
  1272. * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element.
  1273. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1274. */
  1275. withLatestFrom<T2, T3, T4, T5, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable<TResult>;
  1276. /**
  1277. * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element.
  1278. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1279. */
  1280. withLatestFrom<T2, T3, T4, T5, T6, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6) => TResult): Observable<TResult>;
  1281. /**
  1282. * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element.
  1283. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1284. */
  1285. withLatestFrom<T2, T3, T4, T5, T6, T7, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, seventh: ObservableOrPromise<T7>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7) => TResult): Observable<TResult>;
  1286. /**
  1287. * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element.
  1288. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1289. */
  1290. withLatestFrom<T2, T3, T4, T5, T6, T7, T8, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, seventh: ObservableOrPromise<T7>, eighth: ObservableOrPromise<T8>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8) => TResult): Observable<TResult>;
  1291. /**
  1292. * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element.
  1293. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1294. */
  1295. withLatestFrom<T2, T3, T4, T5, T6, T7, T8, T9, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, seventh: ObservableOrPromise<T7>, eighth: ObservableOrPromise<T8>, ninth: ObservableOrPromise<T9>, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9) => TResult): Observable<TResult>;
  1296. /**
  1297. * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element.
  1298. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1299. */
  1300. withLatestFrom<TOther, TResult>(souces: ObservableOrPromise<TOther>[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable<TResult>;
  1301. }
  1302. export interface ObservableStatic {
  1303. /**
  1304. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  1305. * @param arguments Observable sources.
  1306. * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.
  1307. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1308. */
  1309. zip<T1, T2, TResult>(sources: ObservableOrPromise<T2>[], resultSelector?: (item1: T1, ...right: T2[]) => TResult): Observable<TResult>;
  1310. /**
  1311. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  1312. * @param arguments Observable sources.
  1313. * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.
  1314. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1315. */
  1316. zip<T1, T2, TResult>(source1: ObservableOrPromise<T1>, ObservableOrPromise: Observable<T2>, resultSelector?: (item1: T1, item2: T2) => TResult): Observable<TResult>;
  1317. /**
  1318. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  1319. * @param arguments Observable sources.
  1320. * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.
  1321. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1322. */
  1323. zip<T1, T2, T3, TResult>(source1: ObservableOrPromise<T1>, source2: ObservableOrPromise<T2>, source3: ObservableOrPromise<T3>, resultSelector?: (item1: T1, item2: T2, item3: T3) => TResult): Observable<TResult>;
  1324. /**
  1325. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  1326. * @param arguments Observable sources.
  1327. * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.
  1328. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1329. */
  1330. zip<T1, T2, T3, T4, TResult>(source1: Observable<T1>, source2: ObservableOrPromise<T2>, source3: ObservableOrPromise<T3>, source4: ObservableOrPromise<T4>, resultSelector?: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable<TResult>;
  1331. /**
  1332. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  1333. * @param arguments Observable sources.
  1334. * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.
  1335. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1336. */
  1337. zip<T1, T2, T3, T4, T5, TResult>(source1: ObservableOrPromise<T1>, source2: ObservableOrPromise<T2>, source3: ObservableOrPromise<T3>, source4: ObservableOrPromise<T4>, source5: ObservableOrPromise<T5>, resultSelector?: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5) => TResult): Observable<TResult>;
  1338. /**
  1339. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  1340. * @param arguments Observable sources.
  1341. * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.
  1342. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1343. */
  1344. zip<T1, T2, T3, T4, T5, T6, TResult>(source1: ObservableOrPromise<T1>, source2: ObservableOrPromise<T2>, source3: ObservableOrPromise<T3>, source4: ObservableOrPromise<T4>, source5: ObservableOrPromise<T5>, source6: ObservableOrPromise<T6>, resultSelector?: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6) => TResult): Observable<TResult>;
  1345. /**
  1346. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  1347. * @param arguments Observable sources.
  1348. * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.
  1349. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1350. */
  1351. zip<T1, T2, T3, T4, T5, T6, T7, TResult>(source1: ObservableOrPromise<T1>, source2: ObservableOrPromise<T2>, source3: ObservableOrPromise<T3>, source4: ObservableOrPromise<T4>, source5: ObservableOrPromise<T5>, source6: ObservableOrPromise<T6>, source7: ObservableOrPromise<T7>, resultSelector?: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6, item7: T7) => TResult): Observable<TResult>;
  1352. /**
  1353. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  1354. * @param arguments Observable sources.
  1355. * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.
  1356. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1357. */
  1358. zip<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(source1: ObservableOrPromise<T1>, source2: ObservableOrPromise<T2>, source3: ObservableOrPromise<T3>, source4: ObservableOrPromise<T4>, source5: ObservableOrPromise<T5>, source6: ObservableOrPromise<T6>, source7: ObservableOrPromise<T7>, source8: ObservableOrPromise<T8>, resultSelector?: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6, item7: T7, item8: T8) => TResult): Observable<TResult>;
  1359. /**
  1360. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  1361. * @param arguments Observable sources.
  1362. * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.
  1363. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
  1364. */
  1365. zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>(source1: ObservableOrPromise<T1>, source2: ObservableOrPromise<T2>, source3: ObservableOrPromise<T3>, source4: ObservableOrPromise<T4>, source5: ObservableOrPromise<T5>, source6: ObservableOrPromise<T6>, source7: ObservableOrPromise<T7>, source8: ObservableOrPromise<T8>, source9: ObservableOrPromise<T9>, resultSelector?: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6, item7: T7, item8: T8, item9: T9) => TResult): Observable<TResult>;
  1366. }
  1367. export interface Observable<T> {
  1368. /**
  1369. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.
  1370. * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.
  1371. * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.
  1372. */
  1373. zip<T2, TResult>(second: ObservableOrPromise<T2>, resultSelector?: (v1: T, v2: T2) => TResult): Observable<TResult>;
  1374. /**
  1375. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.
  1376. * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.
  1377. * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.
  1378. */
  1379. zip<T2, T3, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, resultSelector?: (v1: T, v2: T2, v3: T3) => TResult): Observable<TResult>;
  1380. /**
  1381. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.
  1382. * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.
  1383. * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.
  1384. */
  1385. zip<T2, T3, T4, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, resultSelector?: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable<TResult>;
  1386. /**
  1387. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.
  1388. * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.
  1389. * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.
  1390. */
  1391. zip<T2, T3, T4, T5, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, resultSelector?: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable<TResult>;
  1392. /**
  1393. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.
  1394. * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.
  1395. * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.
  1396. */
  1397. zip<T2, T3, T4, T5, T6, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, resultSelector?: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6) => TResult): Observable<TResult>;
  1398. /**
  1399. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.
  1400. * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.
  1401. * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.
  1402. */
  1403. zip<T2, T3, T4, T5, T6, T7, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, seventh: ObservableOrPromise<T7>, resultSelector?: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7) => TResult): Observable<TResult>;
  1404. /**
  1405. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.
  1406. * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.
  1407. * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.
  1408. */
  1409. zip<T2, T3, T4, T5, T6, T7, T8, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, seventh: ObservableOrPromise<T7>, eighth: ObservableOrPromise<T8>, resultSelector?: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8) => TResult): Observable<TResult>;
  1410. /**
  1411. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.
  1412. * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.
  1413. * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.
  1414. */
  1415. zip<T2, T3, T4, T5, T6, T7, T8, T9, TResult>(second: ObservableOrPromise<T2>, third: ObservableOrPromise<T3>, fourth: ObservableOrPromise<T4>, fifth: ObservableOrPromise<T5>, sixth: ObservableOrPromise<T6>, seventh: ObservableOrPromise<T7>, eighth: ObservableOrPromise<T8>, ninth: ObservableOrPromise<T9>, resultSelector?: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9) => TResult): Observable<TResult>;
  1416. /**
  1417. * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.
  1418. * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.
  1419. * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.
  1420. */
  1421. zip<TOther, TResult>(souces: ObservableOrPromise<TOther>[], resultSelector?: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable<TResult>;
  1422. }
  1423. export interface ObservableStatic {
  1424. /**
  1425. * Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  1426. * @param arguments Observable sources.
  1427. * @returns {Observable} An observable sequence containing lists of elements at corresponding indexes.
  1428. */
  1429. zipIterable<T>(...sources: Observable<T>[]): Observable<T[]>;
  1430. /**
  1431. * Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  1432. * @param arguments Observable sources.
  1433. * @returns {Observable} An observable sequence containing lists of elements at corresponding indexes.
  1434. */
  1435. zipIterable<T>(sources: Observable<T>[]): Observable<T[]>;
  1436. }
  1437. export interface Observable<T> {
  1438. /**
  1439. * Hides the identity of an observable sequence.
  1440. * @returns {Observable} An observable sequence that hides the identity of the source sequence.
  1441. */
  1442. asObservable(): Observable<T>;
  1443. }
  1444. export interface Observable<T> {
  1445. /**
  1446. * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
  1447. * @param {Number} count Length of each buffer.
  1448. * @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count.
  1449. * @returns {Observable} An observable sequence of buffers.
  1450. */
  1451. bufferWithCount(count: number, skip?: number): Observable<T[]>;
  1452. }
  1453. export interface Observable<T> {
  1454. /**
  1455. * Dematerializes the explicit notification values of an observable sequence as implicit notifications.
  1456. * @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.
  1457. */
  1458. dematerialize<TOrigin>(): Observable<TOrigin>;
  1459. }
  1460. export interface Observable<T> {
  1461. /**
  1462. * Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.
  1463. *
  1464. * var obs = observable.distinctUntilChanged();
  1465. * var obs = observable.distinctUntilChanged(function (x) { return x.id; });
  1466. * var obs = observable.distinctUntilChanged(function (x) { return x.id; }, function (x, y) { return x === y; });
  1467. *
  1468. * @param {Function} [keySelector] A function to compute the comparison key for each element. If not provided, it projects the value.
  1469. * @param {Function} [comparer] Equality comparer for computed key values. If not provided, defaults to an equality comparer function.
  1470. * @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.
  1471. */
  1472. distinctUntilChanged<TValue>(keySelector?: (value: T) => TValue, comparer?: _Comparer<TValue, boolean>): Observable<T>;
  1473. }
  1474. export interface Observable<T> {
  1475. /**
  1476. * Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
  1477. * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  1478. * @param {Function | Observer} observerOrOnNext Action to invoke for each element in the observable sequence or an observer.
  1479. * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
  1480. * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
  1481. * @returns {Observable} The source sequence with the side-effecting behavior applied.
  1482. */
  1483. do(observer: Observer<T>): Observable<T>;
  1484. /**
  1485. * Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
  1486. * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  1487. * @param {Function | Observer} observerOrOnNext Action to invoke for each element in the observable sequence or an observer.
  1488. * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
  1489. * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
  1490. * @returns {Observable} The source sequence with the side-effecting behavior applied.
  1491. */
  1492. tap(observer: Observer<T>): Observable<T>;
  1493. /**
  1494. * Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
  1495. * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  1496. * @param {Function | Observer} observerOrOnNext Action to invoke for each element in the observable sequence or an observer.
  1497. * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
  1498. * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
  1499. * @returns {Observable} The source sequence with the side-effecting behavior applied.
  1500. */
  1501. do(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observable<T>;
  1502. /**
  1503. * Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
  1504. * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  1505. * @param {Function | Observer} observerOrOnNext Action to invoke for each element in the observable sequence or an observer.
  1506. * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
  1507. * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
  1508. * @returns {Observable} The source sequence with the side-effecting behavior applied.
  1509. */
  1510. tap(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observable<T>;
  1511. /**
  1512. * Invokes an action for each element in the observable sequence.
  1513. * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  1514. * @param {Function} onNext Action to invoke for each element in the observable sequence.
  1515. * @param {Any} [thisArg] Object to use as this when executing callback.
  1516. * @returns {Observable} The source sequence with the side-effecting behavior applied.
  1517. */
  1518. doOnNext(onNext: (value: T) => void, thisArg?: any): Observable<T>;
  1519. /**
  1520. * Invokes an action upon exceptional termination of the observable sequence.
  1521. * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  1522. * @param {Function} onError Action to invoke upon exceptional termination of the observable sequence.
  1523. * @param {Any} [thisArg] Object to use as this when executing callback.
  1524. * @returns {Observable} The source sequence with the side-effecting behavior applied.
  1525. */
  1526. doOnError(onError: (exception: any) => void, thisArg?: any): Observable<T>;
  1527. /**
  1528. * Invokes an action upon graceful termination of the observable sequence.
  1529. * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  1530. * @param {Function} onCompleted Action to invoke upon graceful termination of the observable sequence.
  1531. * @param {Any} [thisArg] Object to use as this when executing callback.
  1532. * @returns {Observable} The source sequence with the side-effecting behavior applied.
  1533. */
  1534. doOnCompleted(onCompleted: () => void, thisArg?: any): Observable<T>;
  1535. /**
  1536. * Invokes an action for each element in the observable sequence.
  1537. * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  1538. * @param {Function} onNext Action to invoke for each element in the observable sequence.
  1539. * @param {Any} [thisArg] Object to use as this when executing callback.
  1540. * @returns {Observable} The source sequence with the side-effecting behavior applied.
  1541. */
  1542. tapOnNext(onNext: (value: T) => void, thisArg?: any): Observable<T>;
  1543. /**
  1544. * Invokes an action upon exceptional termination of the observable sequence.
  1545. * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  1546. * @param {Function} onError Action to invoke upon exceptional termination of the observable sequence.
  1547. * @param {Any} [thisArg] Object to use as this when executing callback.
  1548. * @returns {Observable} The source sequence with the side-effecting behavior applied.
  1549. */
  1550. tapOnError(onError: (exception: any) => void, thisArg?: any): Observable<T>;
  1551. /**
  1552. * Invokes an action upon graceful termination of the observable sequence.
  1553. * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  1554. * @param {Function} onCompleted Action to invoke upon graceful termination of the observable sequence.
  1555. * @param {Any} [thisArg] Object to use as this when executing callback.
  1556. * @returns {Observable} The source sequence with the side-effecting behavior applied.
  1557. */
  1558. tapOnCompleted(onCompleted: () => void, thisArg?: any): Observable<T>;
  1559. }
  1560. export interface Observable<T> {
  1561. /**
  1562. * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.
  1563. * @param {Function} finallyAction Action to invoke after the source observable sequence terminates.
  1564. * @returns {Observable} Source sequence with the action-invoking termination behavior applied.
  1565. */
  1566. finally(action: () => void): Observable<T>;
  1567. /**
  1568. * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.
  1569. * @param {Function} finallyAction Action to invoke after the source observable sequence terminates.
  1570. * @returns {Observable} Source sequence with the action-invoking termination behavior applied.
  1571. */
  1572. ensure(action: () => void): Observable<T>;
  1573. }
  1574. export interface Observable<T> {
  1575. /**
  1576. * Ignores all elements in an observable sequence leaving only the termination messages.
  1577. * @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.
  1578. */
  1579. ignoreElements(): Observable<T>;
  1580. }
  1581. export interface Observable<T> {
  1582. /**
  1583. * Materializes the implicit notifications of an observable sequence as explicit notification values.
  1584. * @returns {Observable} An observable sequence containing the materialized notification values from the source sequence.
  1585. */
  1586. materialize(): Observable<T>;
  1587. }
  1588. export interface Observable<T> {
  1589. /**
  1590. * Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely.
  1591. * @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely.
  1592. * @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly.
  1593. */
  1594. repeat(repeatCount?: number): Observable<T>;
  1595. }
  1596. export interface Observable<T> {
  1597. /**
  1598. * Repeats the source observable sequence the specified number of times or until it successfully terminates. If the retry count is not specified, it retries indefinitely.
  1599. * Note if you encounter an error and want it to retry once, then you must use .retry(2);
  1600. *
  1601. * @example
  1602. * var res = retried = retry.repeat();
  1603. * var res = retried = retry.repeat(2);
  1604. * @param {Number} [retryCount] Number of times to retry the sequence. If not provided, retry the sequence indefinitely.
  1605. * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.
  1606. */
  1607. retry(retryCount?: number): Observable<T>;
  1608. }
  1609. export interface Observable<T> {
  1610. /**
  1611. * Repeats the source observable sequence upon error each time the notifier emits or until it successfully terminates.
  1612. * if the notifier completes, the observable sequence completes.
  1613. *
  1614. * @example
  1615. * var timer = Observable.timer(500);
  1616. * var source = observable.retryWhen(timer);
  1617. * @param {Observable} [notifier] An observable that triggers the retries or completes the observable with onNext or onCompleted respectively.
  1618. * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.
  1619. */
  1620. retryWhen(notifier: (errors: Observable<any>) => Observable<any>): Observable<T>;
  1621. }
  1622. export interface Observable<T> {
  1623. /**
  1624. * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value.
  1625. * For aggregation behavior with no intermediate results, see Observable.aggregate.
  1626. * @example
  1627. * var res = source.scan(function (acc, x) { return acc + x; });
  1628. * var res = source.scan(function (acc, x) { return acc + x; }, 0);
  1629. * @param {Function} accumulator An accumulator function to be invoked on each element.
  1630. * @param {Mixed} [seed] The initial accumulator value.
  1631. * @returns {Observable} An observable sequence containing the accumulated values.
  1632. */
  1633. scan<TAcc>(accumulator: _Accumulator<T, TAcc>, seed?: TAcc): Observable<TAcc>;
  1634. /**
  1635. * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value.
  1636. * For aggregation behavior with no intermediate results, see Observable.aggregate.
  1637. * @example
  1638. * var res = source.scan(function (acc, x) { return acc + x; });
  1639. * var res = source.scan(function (acc, x) { return acc + x; }, 0);
  1640. * @param {Function} accumulator An accumulator function to be invoked on each element.
  1641. * @param {Mixed} [seed] The initial accumulator value.
  1642. * @returns {Observable} An observable sequence containing the accumulated values.
  1643. */
  1644. scan(accumulator: _Accumulator<T, T>, seed?: T): Observable<T>;
  1645. }
  1646. export interface Observable<T> {
  1647. /**
  1648. * Bypasses a specified number of elements at the end of an observable sequence.
  1649. * @description
  1650. * This operator accumulates a queue with a length enough to store the first `count` elements. As more elements are
  1651. * received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
  1652. * @param count Number of elements to bypass at the end of the source sequence.
  1653. * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.
  1654. */
  1655. skipLast(count: number): Observable<T>;
  1656. }
  1657. export interface Observable<T> {
  1658. /**
  1659. * Prepends a sequence of values to an observable sequence with an optional scheduler and an argument list of values to prepend.
  1660. * @example
  1661. * var res = source.startWith(1, 2, 3);
  1662. * var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3);
  1663. * @param {Arguments} args The specified values to prepend to the observable sequence
  1664. * @returns {Observable} The source sequence prepended with the specified values.
  1665. */
  1666. startWith(...values: T[]): Observable<T>;
  1667. /**
  1668. * Prepends a sequence of values to an observable sequence with an optional scheduler and an argument list of values to prepend.
  1669. * @example
  1670. * var res = source.startWith(1, 2, 3);
  1671. * var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3);
  1672. * @param {Arguments} args The specified values to prepend to the observable sequence
  1673. * @returns {Observable} The source sequence prepended with the specified values.
  1674. */
  1675. startWith(scheduler: IScheduler, ...values: T[]): Observable<T>;
  1676. }
  1677. export interface Observable<T> {
  1678. /**
  1679. * Returns a specified number of contiguous elements from the end of an observable sequence.
  1680. * @description
  1681. * This operator accumulates a buffer with a length enough to store elements count elements. Upon completion of
  1682. * the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  1683. * @param {Number} count Number of elements to take from the end of the source sequence.
  1684. * @returns {Observable} An observable sequence containing the specified number of elements from the end of the source sequence.
  1685. */
  1686. takeLast(count: number): Observable<T>;
  1687. }
  1688. export interface Observable<T> {
  1689. /**
  1690. * Returns an array with the specified number of contiguous elements from the end of an observable sequence.
  1691. *
  1692. * @description
  1693. * This operator accumulates a buffer with a length enough to store count elements. Upon completion of the
  1694. * source sequence, this buffer is produced on the result sequence.
  1695. * @param {Number} count Number of elements to take from the end of the source sequence.
  1696. * @returns {Observable} An observable sequence containing a single array with the specified number of elements from the end of the source sequence.
  1697. */
  1698. takeLastBuffer(count: number): Observable<T[]>;
  1699. }
  1700. export interface Observable<T> {
  1701. /**
  1702. * Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
  1703. *
  1704. * var res = xs.windowWithCount(10);
  1705. * var res = xs.windowWithCount(10, 1);
  1706. * @param {Number} count Length of each window.
  1707. * @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count.
  1708. * @returns {Observable} An observable sequence of windows.
  1709. */
  1710. windowWithCount(count: number, skip?: number): Observable<Observable<T>>;
  1711. }
  1712. export interface Observable<T> {
  1713. /**
  1714. * One of the Following:
  1715. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  1716. *
  1717. * @example
  1718. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
  1719. * Or:
  1720. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  1721. *
  1722. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  1723. * Or:
  1724. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  1725. *
  1726. * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
  1727. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the
  1728. * source sequence onto which could be either an observable or Promise.
  1729. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  1730. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  1731. */
  1732. concatMap<TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TResult>>): Observable<TResult>;
  1733. /**
  1734. * One of the Following:
  1735. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  1736. *
  1737. * @example
  1738. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
  1739. * Or:
  1740. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  1741. *
  1742. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  1743. * Or:
  1744. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  1745. *
  1746. * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
  1747. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the
  1748. * source sequence onto which could be either an observable or Promise.
  1749. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  1750. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  1751. */
  1752. concatMap<TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TResult>>): Observable<TResult>;
  1753. /**
  1754. * One of the Following:
  1755. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  1756. *
  1757. * @example
  1758. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
  1759. * Or:
  1760. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  1761. *
  1762. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  1763. * Or:
  1764. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  1765. *
  1766. * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
  1767. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the
  1768. * source sequence onto which could be either an observable or Promise.
  1769. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  1770. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  1771. */
  1772. concatMap<TOther, TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  1773. /**
  1774. * One of the Following:
  1775. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  1776. *
  1777. * @example
  1778. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
  1779. * Or:
  1780. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  1781. *
  1782. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  1783. * Or:
  1784. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  1785. *
  1786. * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
  1787. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the
  1788. * source sequence onto which could be either an observable or Promise.
  1789. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  1790. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  1791. */
  1792. concatMap<TOther, TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  1793. /**
  1794. * One of the Following:
  1795. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  1796. *
  1797. * @example
  1798. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
  1799. * Or:
  1800. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  1801. *
  1802. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  1803. * Or:
  1804. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  1805. *
  1806. * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
  1807. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the
  1808. * source sequence onto which could be either an observable or Promise.
  1809. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  1810. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  1811. */
  1812. selectConcat<TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TResult>>): Observable<TResult>;
  1813. /**
  1814. * One of the Following:
  1815. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  1816. *
  1817. * @example
  1818. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
  1819. * Or:
  1820. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  1821. *
  1822. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  1823. * Or:
  1824. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  1825. *
  1826. * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
  1827. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the
  1828. * source sequence onto which could be either an observable or Promise.
  1829. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  1830. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  1831. */
  1832. selectConcat<TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TResult>>): Observable<TResult>;
  1833. /**
  1834. * One of the Following:
  1835. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  1836. *
  1837. * @example
  1838. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
  1839. * Or:
  1840. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  1841. *
  1842. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  1843. * Or:
  1844. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  1845. *
  1846. * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
  1847. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the
  1848. * source sequence onto which could be either an observable or Promise.
  1849. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  1850. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  1851. */
  1852. selectConcat<TOther, TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  1853. /**
  1854. * One of the Following:
  1855. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  1856. *
  1857. * @example
  1858. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
  1859. * Or:
  1860. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  1861. *
  1862. * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  1863. * Or:
  1864. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  1865. *
  1866. * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
  1867. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the
  1868. * source sequence onto which could be either an observable or Promise.
  1869. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  1870. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  1871. */
  1872. selectConcat<TOther, TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  1873. }
  1874. export interface Observable<T> {
  1875. /**
  1876. * Projects each notification of an observable sequence to an observable sequence and concats the resulting observable sequences into one observable sequence.
  1877. * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element.
  1878. * @param {Function} onError A transform function to apply when an error occurs in the source sequence.
  1879. * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached.
  1880. * @param {Any} [thisArg] An optional "this" to use to invoke each transform.
  1881. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.
  1882. */
  1883. concatMapObserver<T, TResult>(onNext: (value: T, i: number) => ObservableOrPromise<TResult>, onError: (error: any) => ObservableOrPromise<any>, onCompleted: () => ObservableOrPromise<any>, thisArg?: any): Observable<TResult>;
  1884. /**
  1885. * Projects each notification of an observable sequence to an observable sequence and concats the resulting observable sequences into one observable sequence.
  1886. * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element.
  1887. * @param {Function} onError A transform function to apply when an error occurs in the source sequence.
  1888. * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached.
  1889. * @param {Any} [thisArg] An optional "this" to use to invoke each transform.
  1890. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.
  1891. */
  1892. selectConcatObserver<T, TResult>(onNext: (value: T, i: number) => ObservableOrPromise<TResult>, onError: (error: any) => ObservableOrPromise<any>, onCompleted: () => ObservableOrPromise<any>, thisArg?: any): Observable<TResult>;
  1893. }
  1894. export interface Observable<T> {
  1895. /**
  1896. * Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.
  1897. *
  1898. * var res = obs = xs.defaultIfEmpty();
  1899. * 2 - obs = xs.defaultIfEmpty(false);
  1900. *
  1901. * @memberOf Observable#
  1902. * @param defaultValue The value to return if the sequence is empty. If not provided, this defaults to null.
  1903. * @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.
  1904. */
  1905. defaultIfEmpty(defaultValue?: T): Observable<T>;
  1906. }
  1907. export interface Observable<T> {
  1908. /**
  1909. * Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer.
  1910. * Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.
  1911. *
  1912. * @example
  1913. * var res = obs = xs.distinct();
  1914. * 2 - obs = xs.distinct(function (x) { return x.id; });
  1915. * 2 - obs = xs.distinct(function (x) { return x.id; }, function (a,b) { return a === b; });
  1916. * @param {Function} [keySelector] A function to compute the comparison key for each element.
  1917. * @param {Function} [comparer] Used to compare items in the collection.
  1918. * @returns {Observable} An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.
  1919. */
  1920. distinct<TKey>(keySelector?: (value: T) => TKey, keySerializer?: (key: TKey) => string): Observable<T>;
  1921. }
  1922. export interface Observable<T> {
  1923. /**
  1924. * Groups the elements of an observable sequence according to a specified key selector function.
  1925. * A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  1926. * key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  1927. *
  1928. * @example
  1929. * var res = observable.groupByUntil(function (x) { return x.id; }, null, function () { return Rx.Observable.never(); });
  1930. * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); });
  1931. * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }, function (x) { return x.toString(); });
  1932. * @param {Function} keySelector A function to extract the key for each element.
  1933. * @param {Function} durationSelector A function to signal the expiration of a group.
  1934. * @returns {Observable}
  1935. * A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  1936. * If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.
  1937. *
  1938. */
  1939. groupByUntil<TKey, TDuration>(keySelector: (value: T) => TKey, skipElementSelector: boolean, durationSelector: (group: GroupedObservable<TKey, T>) => Observable<TDuration>, keySerializer?: (key: TKey) => string): Observable<GroupedObservable<TKey, T>>;
  1940. /**
  1941. * Groups the elements of an observable sequence according to a specified key selector function.
  1942. * A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  1943. * key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  1944. *
  1945. * @example
  1946. * var res = observable.groupByUntil(function (x) { return x.id; }, null, function () { return Rx.Observable.never(); });
  1947. * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); });
  1948. * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }, function (x) { return x.toString(); });
  1949. * @param {Function} keySelector A function to extract the key for each element.
  1950. * @param {Function} durationSelector A function to signal the expiration of a group.
  1951. * @returns {Observable}
  1952. * A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  1953. * If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.
  1954. *
  1955. */
  1956. groupByUntil<TKey, TElement, TDuration>(keySelector: (value: T) => TKey, elementSelector: (value: T) => TElement, durationSelector: (group: GroupedObservable<TKey, TElement>) => Observable<TDuration>, keySerializer?: (key: TKey) => string): Observable<GroupedObservable<TKey, TElement>>;
  1957. }
  1958. export interface Observable<T> {
  1959. /**
  1960. * Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
  1961. *
  1962. * @example
  1963. * var res = observable.groupBy(function (x) { return x.id; });
  1964. * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; });
  1965. * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function (x) { return x.toString(); });
  1966. * @param {Function} keySelector A function to extract the key for each element.
  1967. * @param {Function} [elementSelector] A function to map each source element to an element in an observable group.
  1968. * @returns {Observable} A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  1969. */
  1970. groupBy<TKey, TElement>(keySelector: (value: T) => TKey, skipElementSelector?: boolean, keySerializer?: (key: TKey) => string): Observable<GroupedObservable<TKey, T>>;
  1971. /**
  1972. * Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
  1973. *
  1974. * @example
  1975. * var res = observable.groupBy(function (x) { return x.id; });
  1976. * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; });
  1977. * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function (x) { return x.toString(); });
  1978. * @param {Function} keySelector A function to extract the key for each element.
  1979. * @param {Function} [elementSelector] A function to map each source element to an element in an observable group.
  1980. * @returns {Observable} A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  1981. */
  1982. groupBy<TKey, TElement>(keySelector: (value: T) => TKey, elementSelector: (value: T) => TElement, keySerializer?: (key: TKey) => string): Observable<GroupedObservable<TKey, TElement>>;
  1983. }
  1984. export interface Observable<T> {
  1985. /**
  1986. * Projects each element of an observable sequence into a new form by incorporating the element's index.
  1987. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  1988. * @param {Any} [thisArg] Object to use as this when executing callback.
  1989. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.
  1990. */
  1991. select<TResult>(selector: _Selector<T, TResult>, thisArg?: any): Observable<TResult>;
  1992. /**
  1993. * Projects each element of an observable sequence into a new form by incorporating the element's index.
  1994. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  1995. * @param {Any} [thisArg] Object to use as this when executing callback.
  1996. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.
  1997. */
  1998. map<TResult>(selector: _Selector<T, TResult>, thisArg?: any): Observable<TResult>;
  1999. }
  2000. export interface Observable<T> {
  2001. /**
  2002. * Retrieves the value of a specified nested property from all elements in
  2003. * the Observable sequence.
  2004. * @param {Arguments} arguments The nested properties to pluck.
  2005. * @returns {Observable} Returns a new Observable sequence of property values.
  2006. */
  2007. pluck<TResult>(prop: string): Observable<TResult>;
  2008. }
  2009. export interface Observable<T> {
  2010. /**
  2011. * One of the Following:
  2012. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  2013. *
  2014. * @example
  2015. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
  2016. * Or:
  2017. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  2018. *
  2019. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  2020. * Or:
  2021. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  2022. *
  2023. * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
  2024. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the source sequence onto which could be either an observable or Promise.
  2025. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  2026. * @param {Any} [thisArg] Object to use as this when executing callback.
  2027. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  2028. */
  2029. flatMap<TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TResult>>): Observable<TResult>;
  2030. /**
  2031. * One of the Following:
  2032. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  2033. *
  2034. * @example
  2035. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
  2036. * Or:
  2037. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  2038. *
  2039. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  2040. * Or:
  2041. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  2042. *
  2043. * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
  2044. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the source sequence onto which could be either an observable or Promise.
  2045. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  2046. * @param {Any} [thisArg] Object to use as this when executing callback.
  2047. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  2048. */
  2049. flatMap<TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TResult>>): Observable<TResult>;
  2050. /**
  2051. * One of the Following:
  2052. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  2053. *
  2054. * @example
  2055. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
  2056. * Or:
  2057. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  2058. *
  2059. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  2060. * Or:
  2061. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  2062. *
  2063. * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
  2064. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the source sequence onto which could be either an observable or Promise.
  2065. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  2066. * @param {Any} [thisArg] Object to use as this when executing callback.
  2067. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  2068. */
  2069. flatMap<TOther, TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  2070. /**
  2071. * One of the Following:
  2072. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  2073. *
  2074. * @example
  2075. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
  2076. * Or:
  2077. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  2078. *
  2079. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  2080. * Or:
  2081. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  2082. *
  2083. * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
  2084. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the source sequence onto which could be either an observable or Promise.
  2085. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  2086. * @param {Any} [thisArg] Object to use as this when executing callback.
  2087. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  2088. */
  2089. flatMap<TOther, TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  2090. /**
  2091. * One of the Following:
  2092. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  2093. *
  2094. * @example
  2095. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
  2096. * Or:
  2097. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  2098. *
  2099. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  2100. * Or:
  2101. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  2102. *
  2103. * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
  2104. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the source sequence onto which could be either an observable or Promise.
  2105. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  2106. * @param {Any} [thisArg] Object to use as this when executing callback.
  2107. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  2108. */
  2109. selectMany<TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TResult>>): Observable<TResult>;
  2110. /**
  2111. * One of the Following:
  2112. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  2113. *
  2114. * @example
  2115. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
  2116. * Or:
  2117. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  2118. *
  2119. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  2120. * Or:
  2121. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  2122. *
  2123. * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
  2124. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the source sequence onto which could be either an observable or Promise.
  2125. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  2126. * @param {Any} [thisArg] Object to use as this when executing callback.
  2127. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  2128. */
  2129. selectMany<TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TResult>>): Observable<TResult>;
  2130. /**
  2131. * One of the Following:
  2132. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  2133. *
  2134. * @example
  2135. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
  2136. * Or:
  2137. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  2138. *
  2139. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  2140. * Or:
  2141. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  2142. *
  2143. * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
  2144. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the source sequence onto which could be either an observable or Promise.
  2145. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  2146. * @param {Any} [thisArg] Object to use as this when executing callback.
  2147. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  2148. */
  2149. selectMany<TOther, TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  2150. /**
  2151. * One of the Following:
  2152. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  2153. *
  2154. * @example
  2155. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
  2156. * Or:
  2157. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  2158. *
  2159. * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  2160. * Or:
  2161. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  2162. *
  2163. * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
  2164. * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the source sequence onto which could be either an observable or Promise.
  2165. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  2166. * @param {Any} [thisArg] Object to use as this when executing callback.
  2167. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  2168. */
  2169. selectMany<TOther, TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  2170. }
  2171. export interface Observable<T> {
  2172. /**
  2173. * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  2174. * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element.
  2175. * @param {Function} onError A transform function to apply when an error occurs in the source sequence.
  2176. * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached.
  2177. * @param {Any} [thisArg] An optional "this" to use to invoke each transform.
  2178. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.
  2179. */
  2180. selectManyObserver<T2, T3, T4>(onNext: (value: T, index: number) => Observable<T2>, onError: (exception: any) => Observable<T3>, onCompleted: () => Observable<T4>, thisArg?: any): Observable<T2 | T3 | T4>;
  2181. /**
  2182. * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  2183. * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element.
  2184. * @param {Function} onError A transform function to apply when an error occurs in the source sequence.
  2185. * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached.
  2186. * @param {Any} [thisArg] An optional "this" to use to invoke each transform.
  2187. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.
  2188. */
  2189. flatMapObserver<T2, T3, T4>(onNext: (value: T, index: number) => Observable<T2>, onError: (exception: any) => Observable<T3>, onCompleted: () => Observable<T4>, thisArg?: any): Observable<T2 | T3 | T4>;
  2190. }
  2191. export interface Observable<T> {
  2192. /**
  2193. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  2194. * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
  2195. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  2196. * @param {Any} [thisArg] Object to use as this when executing callback.
  2197. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  2198. * and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
  2199. */
  2200. selectSwitch<TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TResult>>): Observable<TResult>;
  2201. /**
  2202. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  2203. * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
  2204. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  2205. * @param {Any} [thisArg] Object to use as this when executing callback.
  2206. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  2207. * and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
  2208. */
  2209. selectSwitch<TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TResult>>): Observable<TResult>;
  2210. /**
  2211. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  2212. * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
  2213. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  2214. * @param {Any} [thisArg] Object to use as this when executing callback.
  2215. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  2216. * and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
  2217. */
  2218. selectSwitch<TOther, TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  2219. /**
  2220. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  2221. * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
  2222. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  2223. * @param {Any} [thisArg] Object to use as this when executing callback.
  2224. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  2225. * and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
  2226. */
  2227. selectSwitch<TOther, TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  2228. /**
  2229. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  2230. * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
  2231. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  2232. * @param {Any} [thisArg] Object to use as this when executing callback.
  2233. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  2234. * and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
  2235. */
  2236. flatMapLatest<TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TResult>>): Observable<TResult>;
  2237. /**
  2238. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  2239. * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
  2240. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  2241. * @param {Any} [thisArg] Object to use as this when executing callback.
  2242. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  2243. * and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
  2244. */
  2245. flatMapLatest<TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TResult>>): Observable<TResult>;
  2246. /**
  2247. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  2248. * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
  2249. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  2250. * @param {Any} [thisArg] Object to use as this when executing callback.
  2251. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  2252. * and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
  2253. */
  2254. flatMapLatest<TOther, TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  2255. /**
  2256. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  2257. * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
  2258. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  2259. * @param {Any} [thisArg] Object to use as this when executing callback.
  2260. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  2261. * and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
  2262. */
  2263. flatMapLatest<TOther, TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  2264. }
  2265. export interface Observable<T> {
  2266. /**
  2267. * Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
  2268. * @param {Number} count The number of elements to skip before returning the remaining elements.
  2269. * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.
  2270. */
  2271. skip(count: number): Observable<T>;
  2272. }
  2273. export interface Observable<T> {
  2274. /**
  2275. * Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  2276. * The element's index is used in the logic of the predicate function.
  2277. *
  2278. * var res = source.skipWhile(function (value) { return value < 10; });
  2279. * var res = source.skipWhile(function (value, index) { return value < 10 || index < 10; });
  2280. * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.
  2281. * @param {Any} [thisArg] Object to use as this when executing callback.
  2282. * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.
  2283. */
  2284. skipWhile(predicate: _Predicate<T>, thisArg?: any): Observable<T>;
  2285. }
  2286. export interface Observable<T> {
  2287. /**
  2288. * Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of take(0).
  2289. *
  2290. * var res = source.take(5);
  2291. * var res = source.take(0, Rx.Scheduler.timeout);
  2292. * @param {Number} count The number of elements to return.
  2293. * @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case <paramref name="count count</paramref> is set to 0.
  2294. * @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.
  2295. */
  2296. take(count: number, scheduler?: IScheduler): Observable<T>;
  2297. }
  2298. export interface Observable<T> {
  2299. /**
  2300. * Returns elements from an observable sequence as long as a specified condition is true.
  2301. * The element's index is used in the logic of the predicate function.
  2302. * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.
  2303. * @param {Any} [thisArg] Object to use as this when executing callback.
  2304. * @returns {Observable} An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.
  2305. */
  2306. takeWhile(predicate: _Predicate<T>, thisArg?: any): Observable<T>;
  2307. }
  2308. export interface Observable<T> {
  2309. /**
  2310. * Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
  2311. *
  2312. * @example
  2313. * var res = source.where(function (value) { return value < 10; });
  2314. * var res = source.where(function (value, index) { return value < 10 || index < 10; });
  2315. * @param {Function} predicate A function to test each source element for a condition; the second parameter of the function represents the index of the source element.
  2316. * @param {Any} [thisArg] Object to use as this when executing callback.
  2317. * @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.
  2318. */
  2319. where(predicate: _Predicate<T>, thisArg?: any): Observable<T>;
  2320. /**
  2321. * Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
  2322. *
  2323. * @example
  2324. * var res = source.where(function (value) { return value < 10; });
  2325. * var res = source.where(function (value, index) { return value < 10 || index < 10; });
  2326. * @param {Function} predicate A function to test each source element for a condition; the second parameter of the function represents the index of the source element.
  2327. * @param {Any} [thisArg] Object to use as this when executing callback.
  2328. * @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.
  2329. */
  2330. filter(predicate: _Predicate<T>, thisArg?: any): Observable<T>;
  2331. }
  2332. export interface Observable<T> {
  2333. /**
  2334. * Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.
  2335. * For aggregation behavior with incremental intermediate results, see Observable.scan.
  2336. * @param {Function} accumulator An accumulator function to be invoked on each element.
  2337. * @param {Any} [seed] The initial accumulator value.
  2338. * @returns {Observable} An observable sequence containing a single element with the final accumulator value.
  2339. */
  2340. reduce<TAcc>(accumulator: _Accumulator<T, TAcc>, seed?: TAcc): Observable<TAcc>;
  2341. /**
  2342. * Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.
  2343. * For aggregation behavior with incremental intermediate results, see Observable.scan.
  2344. * @param {Function} accumulator An accumulator function to be invoked on each element.
  2345. * @param {Any} [seed] The initial accumulator value.
  2346. * @returns {Observable} An observable sequence containing a single element with the final accumulator value.
  2347. */
  2348. reduce(accumulator: _Accumulator<T, T>, seed?: T): Observable<T>;
  2349. }
  2350. export interface Observable<T> {
  2351. /**
  2352. * Determines whether any element of an observable sequence satisfies a condition if present, else if any items are in the sequence.
  2353. * @param {Function} [predicate] A function to test each element for a condition.
  2354. * @returns {Observable} An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate if given, else if any items are in the sequence.
  2355. */
  2356. some(predicate?: _Predicate<T>, thisArg?: any): Observable<boolean>; // alias for any
  2357. }
  2358. export interface Observable<T> {
  2359. /**
  2360. * Determines whether an observable sequence is empty.
  2361. * @returns {Observable} An observable sequence containing a single element determining whether the source sequence is empty.
  2362. */
  2363. isEmpty(): Observable<boolean>;
  2364. }
  2365. export interface Observable<T> {
  2366. /**
  2367. * Determines whether all elements of an observable sequence satisfy a condition.
  2368. * @param {Function} [predicate] A function to test each element for a condition.
  2369. * @param {Any} [thisArg] Object to use as this when executing callback.
  2370. * @returns {Observable} An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate.
  2371. */
  2372. every(predicate?: _Predicate<T>, thisArg?: any): Observable<boolean>; // alias for all
  2373. }
  2374. export interface Observable<T> {
  2375. /**
  2376. * Determines whether an observable sequence includes a specified element with an optional equality comparer.
  2377. * @param searchElement The value to locate in the source sequence.
  2378. * @param {Number} [fromIndex] An equality comparer to compare elements.
  2379. * @returns {Observable} An observable sequence containing a single element determining whether the source sequence includes an element that has the specified value from the given index.
  2380. */
  2381. includes(value: T, comparer?: _Comparer<T, boolean>): Observable<boolean>;
  2382. }
  2383. export interface Observable<T> {
  2384. /**
  2385. * Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items.
  2386. * @example
  2387. * res = source.count();
  2388. * res = source.count(function (x) { return x > 3; });
  2389. * @param {Function} [predicate]A function to test each element for a condition.
  2390. * @param {Any} [thisArg] Object to use as this when executing callback.
  2391. * @returns {Observable} An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function if provided, else the count of items in the sequence.
  2392. */
  2393. count(predicate?: _Predicate<T>, thisArg?: any): Observable<number>;
  2394. }
  2395. export interface Observable<T> {
  2396. /**
  2397. * Returns the first index at which a given element can be found in the observable sequence, or -1 if it is not present.
  2398. * @param {Any} searchElement Element to locate in the array.
  2399. * @param {Number} [fromIndex] The index to start the search. If not specified, defaults to 0.
  2400. * @returns {Observable} And observable sequence containing the first index at which a given element can be found in the observable sequence, or -1 if it is not present.
  2401. */
  2402. indexOf(element: T, fromIndex?: number): Observable<number>;
  2403. }
  2404. export interface Observable<T> {
  2405. /**
  2406. * Computes the sum of a sequence of values that are obtained by invoking an optional transform function on each element of the input sequence, else if not specified computes the sum on each item in the sequence.
  2407. * @param {Function} [selector] A transform function to apply to each element.
  2408. * @param {Any} [thisArg] Object to use as this when executing callback.
  2409. * @returns {Observable} An observable sequence containing a single element with the sum of the values in the source sequence.
  2410. */
  2411. sum(keySelector?: _Selector<T, number>, thisArg?: any): Observable<number>;
  2412. }
  2413. export interface Observable<T> {
  2414. /**
  2415. * Returns the elements in an observable sequence with the minimum key value according to the specified comparer.
  2416. * @example
  2417. * var res = source.minBy(function (x) { return x.value; });
  2418. * var res = source.minBy(function (x) { return x.value; }, function (x, y) { return x - y; });
  2419. * @param {Function} keySelector Key selector function.
  2420. * @param {Function} [comparer] Comparer used to compare key values.
  2421. * @returns {Observable} An observable sequence containing a list of zero or more elements that have a minimum key value.
  2422. */
  2423. minBy<TKey>(keySelector: (item: T) => TKey, comparer: _Comparer<TKey, number>): Observable<T>;
  2424. /**
  2425. * Returns the elements in an observable sequence with the minimum key value according to the specified comparer.
  2426. * @example
  2427. * var res = source.minBy(function (x) { return x.value; });
  2428. * var res = source.minBy(function (x) { return x.value; }, function (x, y) { return x - y; });
  2429. * @param {Function} keySelector Key selector function.
  2430. * @param {Function} [comparer] Comparer used to compare key values.
  2431. * @returns {Observable} An observable sequence containing a list of zero or more elements that have a minimum key value.
  2432. */
  2433. minBy(keySelector: (item: T) => number): Observable<T>;
  2434. }
  2435. export interface Observable<T> {
  2436. /**
  2437. * Returns the minimum element in an observable sequence according to the optional comparer else a default greater than less than check.
  2438. * @example
  2439. * var res = source.min();
  2440. * var res = source.min(function (x, y) { return x.value - y.value; });
  2441. * @param {Function} [comparer] Comparer used to compare elements.
  2442. * @returns {Observable} An observable sequence containing a single element with the minimum element in the source sequence.
  2443. */
  2444. min(comparer?: _Comparer<T, number>): Observable<number>;
  2445. }
  2446. export interface Observable<T> {
  2447. /**
  2448. * Returns the elements in an observable sequence with the maximum key value according to the specified comparer.
  2449. * @example
  2450. * var res = source.maxBy(function (x) { return x.value; });
  2451. * var res = source.maxBy(function (x) { return x.value; }, function (x, y) { return x - y;; });
  2452. * @param {Function} keySelector Key selector function.
  2453. * @param {Function} [comparer] Comparer used to compare key values.
  2454. * @returns {Observable} An observable sequence containing a list of zero or more elements that have a maximum key value.
  2455. */
  2456. maxBy<TKey>(keySelector: (item: T) => TKey, comparer: _Comparer<TKey, number>): Observable<T>;
  2457. /**
  2458. * Returns the elements in an observable sequence with the maximum key value according to the specified comparer.
  2459. * @example
  2460. * var res = source.maxBy(function (x) { return x.value; });
  2461. * var res = source.maxBy(function (x) { return x.value; }, function (x, y) { return x - y;; });
  2462. * @param {Function} keySelector Key selector function.
  2463. * @param {Function} [comparer] Comparer used to compare key values.
  2464. * @returns {Observable} An observable sequence containing a list of zero or more elements that have a maximum key value.
  2465. */
  2466. maxBy(keySelector: (item: T) => number): Observable<T>;
  2467. }
  2468. export interface Observable<T> {
  2469. /**
  2470. * Returns the maximum value in an observable sequence according to the specified comparer.
  2471. * @example
  2472. * var res = source.max();
  2473. * var res = source.max(function (x, y) { return x.value - y.value; });
  2474. * @param {Function} [comparer] Comparer used to compare elements.
  2475. * @returns {Observable} An observable sequence containing a single element with the maximum element in the source sequence.
  2476. */
  2477. max(comparer?: _Comparer<T, number>): Observable<number>;
  2478. }
  2479. export interface Observable<T> {
  2480. /**
  2481. * Computes the average of an observable sequence of values that are in the sequence or obtained by invoking a transform function on each element of the input sequence if present.
  2482. * @param {Function} [selector] A transform function to apply to each element.
  2483. * @param {Any} [thisArg] Object to use as this when executing callback.
  2484. * @returns {Observable} An observable sequence containing a single element with the average of the sequence of values.
  2485. */
  2486. average(keySelector?: _Selector<T, number>, thisArg?: any): Observable<number>;
  2487. }
  2488. export interface Observable<T> {
  2489. /**
  2490. * Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.
  2491. *
  2492. * @example
  2493. * var res = res = source.sequenceEqual([1,2,3]);
  2494. * var res = res = source.sequenceEqual([{ value: 42 }], function (x, y) { return x.value === y.value; });
  2495. * 3 - res = source.sequenceEqual(Rx.Observable.returnValue(42));
  2496. * 4 - res = source.sequenceEqual(Rx.Observable.returnValue({ value: 42 }), function (x, y) { return x.value === y.value; });
  2497. * @param {Observable} second Second observable sequence or array to compare.
  2498. * @param {Function} [comparer] Comparer used to compare elements of both sequences.
  2499. * @returns {Observable} An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the specified equality comparer.
  2500. */
  2501. sequenceEqual(second: ObservableOrPromise<T> | ArrayOrIterable<T>, comparer?: _Comparer<T, boolean>): Observable<boolean>;
  2502. /**
  2503. * Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.
  2504. *
  2505. * @example
  2506. * var res = res = source.sequenceEqual([1,2,3]);
  2507. * var res = res = source.sequenceEqual([{ value: 42 }], function (x, y) { return x.value === y.value; });
  2508. * 3 - res = source.sequenceEqual(Rx.Observable.returnValue(42));
  2509. * 4 - res = source.sequenceEqual(Rx.Observable.returnValue({ value: 42 }), function (x, y) { return x.value === y.value; });
  2510. * @param {Observable} second Second observable sequence or array to compare.
  2511. * @param {Function} [comparer] Comparer used to compare elements of both sequences.
  2512. * @returns {Observable} An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the specified equality comparer.
  2513. */
  2514. sequenceEqual<TOther>(second: ObservableOrPromise<T> | ArrayOrIterable<T>, comparer: _Comparer<T | TOther, boolean>): Observable<boolean>;
  2515. }
  2516. export interface Observable<T> {
  2517. /**
  2518. * Returns the element at a specified index in a sequence or default value if not found.
  2519. * @param {Number} index The zero-based index of the element to retrieve.
  2520. * @param {Any} [defaultValue] The default value to use if elementAt does not find a value.
  2521. * @returns {Observable} An observable sequence that produces the element at the specified position in the source sequence.
  2522. */
  2523. elementAt(index: number): Observable<T>;
  2524. }
  2525. export interface Observable<T> {
  2526. /**
  2527. * Returns the only element of an observable sequence that satisfies the condition in the optional predicate, and reports an exception if there is not exactly one element in the observable sequence.
  2528. * @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.
  2529. * @param {Any} [thisArg] Object to use as `this` when executing the predicate.
  2530. * @returns {Observable} Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.
  2531. */
  2532. single(predicate?: _Predicate<T>, thisArg?: any): Observable<T>;
  2533. }
  2534. export interface Observable<T> {
  2535. /**
  2536. * Returns the first element of an observable sequence that satisfies the condition in the predicate if present else the first item in the sequence.
  2537. * @returns {Observable} Sequence containing the first element in the observable sequence that satisfies the condition in the predicate if provided, else the first item in the sequence.
  2538. */
  2539. first(predicate?: _Predicate<T>, thisArg?: any): Observable<T>;
  2540. }
  2541. export interface Observable<T> {
  2542. /**
  2543. * Returns the last element of an observable sequence that satisfies the condition in the predicate if specified, else the last element.
  2544. * @returns {Observable} Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.
  2545. */
  2546. last(predicate?: _Predicate<T>, thisArg?: any): Observable<T>;
  2547. }
  2548. export interface Observable<T> {
  2549. /**
  2550. * Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire Observable sequence.
  2551. * @param {Function} predicate The predicate that defines the conditions of the element to search for.
  2552. * @param {Any} [thisArg] Object to use as `this` when executing the predicate.
  2553. * @returns {Observable} An Observable sequence with the first element that matches the conditions defined by the specified predicate, if found; otherwise, undefined.
  2554. */
  2555. find(predicate: _Predicate<T>, thisArg?: any): Observable<T>;
  2556. }
  2557. export interface Observable<T> {
  2558. /**
  2559. * Searches for an element that matches the conditions defined by the specified predicate, and returns
  2560. * an Observable sequence with the zero-based index of the first occurrence within the entire Observable sequence.
  2561. * @param {Function} predicate The predicate that defines the conditions of the element to search for.
  2562. * @param {Any} [thisArg] Object to use as `this` when executing the predicate.
  2563. * @returns {Observable} An Observable sequence with the zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.
  2564. */
  2565. findIndex(predicate: _Predicate<T>, thisArg?: any): Observable<number>;
  2566. }
  2567. export interface ObservableStatic {
  2568. wrap<T>(fn: Function): Observable<T>;
  2569. spawn<T>(fn: Function): Observable<T>;
  2570. }
  2571. export interface ObservableStatic {
  2572. /**
  2573. * Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence.
  2574. *
  2575. * @example
  2576. * var res = Rx.Observable.start(function () { console.log('hello'); });
  2577. * var res = Rx.Observable.start(function () { console.log('hello'); }, Rx.Scheduler.timeout);
  2578. * var res = Rx.Observable.start(function () { this.log('hello'); }, Rx.Scheduler.timeout, console);
  2579. *
  2580. * @param {Function} func Function to run asynchronously.
  2581. * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
  2582. * @param [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2583. * @returns {Observable} An observable sequence exposing the function's result value, or an exception.
  2584. *
  2585. * Remarks
  2586. * * The function is called immediately, not during the subscription of the resulting sequence.
  2587. * * Multiple subscriptions to the resulting sequence can observe the function's result.
  2588. */
  2589. start<T>(func: () => T, scheduler?: IScheduler, context?: any): Observable<T>;
  2590. }
  2591. export interface ObservableStatic {
  2592. /**
  2593. * Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  2594. * @param {Function} function Function to convert to an asynchronous function.
  2595. * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
  2596. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2597. * @returns {Function} Asynchronous function.
  2598. */
  2599. toAsync<TResult>(func: () => TResult, context?: any, scheduler?: IScheduler): () => Observable<TResult>;
  2600. /**
  2601. * Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  2602. * @param {Function} function Function to convert to an asynchronous function.
  2603. * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
  2604. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2605. * @returns {Function} Asynchronous function.
  2606. */
  2607. toAsync<T1, TResult>(func: (arg1: T1) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1) => Observable<TResult>;
  2608. /**
  2609. * Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  2610. * @param {Function} function Function to convert to an asynchronous function.
  2611. * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
  2612. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2613. * @returns {Function} Asynchronous function.
  2614. */
  2615. toAsync<T1, T2, TResult>(func: (arg1: T1, arg2: T2) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2) => Observable<TResult>;
  2616. /**
  2617. * Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  2618. * @param {Function} function Function to convert to an asynchronous function.
  2619. * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
  2620. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2621. * @returns {Function} Asynchronous function.
  2622. */
  2623. toAsync<T1, T2, T3, TResult>(func: (arg1: T1, arg2: T2, arg3: T3) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3: T3) => Observable<TResult>;
  2624. /**
  2625. * Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  2626. * @param {Function} function Function to convert to an asynchronous function.
  2627. * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
  2628. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2629. * @returns {Function} Asynchronous function.
  2630. */
  2631. toAsync<T1, T2, T3, T4, TResult>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Observable<TResult>;
  2632. }
  2633. export interface ObservableStatic {
  2634. /**
  2635. * Converts a callback function to an observable sequence.
  2636. *
  2637. * @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.
  2638. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2639. * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.
  2640. * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.
  2641. */
  2642. fromCallback<TResult>(func: Function, context: any, selector: Function): (...args: any[]) => Observable<TResult>;
  2643. /**
  2644. * Converts a callback function to an observable sequence.
  2645. *
  2646. * @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.
  2647. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2648. * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.
  2649. * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.
  2650. */
  2651. fromCallback<TResult, T1>(func: (arg1: T1, callback: (result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1) => Observable<TResult>;
  2652. /**
  2653. * Converts a callback function to an observable sequence.
  2654. *
  2655. * @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.
  2656. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2657. * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.
  2658. * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.
  2659. */
  2660. fromCallback<TResult, T1, T2>(func: (arg1: T1, arg2: T2, callback: (result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2) => Observable<TResult>;
  2661. /**
  2662. * Converts a callback function to an observable sequence.
  2663. *
  2664. * @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.
  2665. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2666. * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.
  2667. * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.
  2668. */
  2669. fromCallback<TResult, T1, T2, T3>(func: (arg1: T1, arg2: T2, arg3: T3, callback: (result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2, arg3: T3) => Observable<TResult>;
  2670. /**
  2671. * Converts a callback function to an observable sequence.
  2672. *
  2673. * @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.
  2674. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2675. * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.
  2676. * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.
  2677. */
  2678. fromCallback<TResult, T1, T2, T3, T4>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Observable<TResult>;
  2679. /**
  2680. * Converts a callback function to an observable sequence.
  2681. *
  2682. * @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.
  2683. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2684. * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.
  2685. * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.
  2686. */
  2687. fromCallback<TResult, T1, T2, T3, T4, T5>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Observable<TResult>;
  2688. /**
  2689. * Converts a callback function to an observable sequence.
  2690. *
  2691. * @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.
  2692. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2693. * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.
  2694. * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.
  2695. */
  2696. fromCallback<TResult, T1, T2, T3, T4, T5, T6>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Observable<TResult>;
  2697. /**
  2698. * Converts a callback function to an observable sequence.
  2699. *
  2700. * @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.
  2701. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2702. * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.
  2703. * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.
  2704. */
  2705. fromCallback<TResult, T1, T2, T3, T4, T5, T6, T7>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, callback: (result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7) => Observable<TResult>;
  2706. /**
  2707. * Converts a callback function to an observable sequence.
  2708. *
  2709. * @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.
  2710. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2711. * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.
  2712. * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.
  2713. */
  2714. fromCallback<TResult, T1, T2, T3, T4, T5, T6, T7, T8>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8, callback: (result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8) => Observable<TResult>;
  2715. /**
  2716. * Converts a callback function to an observable sequence.
  2717. *
  2718. * @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.
  2719. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2720. * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.
  2721. * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.
  2722. */
  2723. fromCallback<TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8, arg9: T9, callback: (result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8, arg9: T9) => Observable<TResult>;
  2724. }
  2725. export interface ObservableStatic {
  2726. /**
  2727. * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
  2728. * @param {Function} func The function to call
  2729. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2730. * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.
  2731. * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
  2732. */
  2733. fromNodeCallback<TResult>(func: Function, context?: any, selector?: Function): (...args: any[]) => Observable<TResult>;
  2734. /**
  2735. * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
  2736. * @param {Function} func The function to call
  2737. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2738. * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.
  2739. * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
  2740. */
  2741. fromNodeCallback<TResult, T1>(func: (arg1: T1, callback: (err: any, result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1) => Observable<TResult>;
  2742. /**
  2743. * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
  2744. * @param {Function} func The function to call
  2745. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2746. * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.
  2747. * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
  2748. */
  2749. fromNodeCallback<TResult, T1, T2>(func: (arg1: T1, arg2: T2, callback: (err: any, result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2) => Observable<TResult>;
  2750. /**
  2751. * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
  2752. * @param {Function} func The function to call
  2753. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2754. * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.
  2755. * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
  2756. */
  2757. fromNodeCallback<TResult, T1, T2, T3>(func: (arg1: T1, arg2: T2, arg3: T3, callback: (err: any, result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2, arg3: T3) => Observable<TResult>;
  2758. /**
  2759. * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
  2760. * @param {Function} func The function to call
  2761. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2762. * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.
  2763. * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
  2764. */
  2765. fromNodeCallback<TResult, T1, T2, T3, T4>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: any, result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Observable<TResult>;
  2766. /**
  2767. * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
  2768. * @param {Function} func The function to call
  2769. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2770. * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.
  2771. * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
  2772. */
  2773. fromNodeCallback<TResult, T1, T2, T3, T4, T5>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: any, result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Observable<TResult>;
  2774. /**
  2775. * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
  2776. * @param {Function} func The function to call
  2777. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2778. * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.
  2779. * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
  2780. */
  2781. fromNodeCallback<TResult, T1, T2, T3, T4, T5, T6>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: any, result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Observable<TResult>;
  2782. /**
  2783. * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
  2784. * @param {Function} func The function to call
  2785. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2786. * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.
  2787. * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
  2788. */
  2789. fromNodeCallback<TResult, T1, T2, T3, T4, T5, T6, T7>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, callback: (err: any, result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7) => Observable<TResult>;
  2790. /**
  2791. * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
  2792. * @param {Function} func The function to call
  2793. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2794. * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.
  2795. * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
  2796. */
  2797. fromNodeCallback<TResult, T1, T2, T3, T4, T5, T6, T7, T8>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8, callback: (err: any, result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8) => Observable<TResult>;
  2798. /**
  2799. * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
  2800. * @param {Function} func The function to call
  2801. * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
  2802. * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.
  2803. * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
  2804. */
  2805. fromNodeCallback<TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8, arg9: T9, callback: (err: any, result: TResult) => any) => any, context?: any, selector?: Function): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8, arg9: T9) => Observable<TResult>;
  2806. }
  2807. export interface ObservableStatic {
  2808. /**
  2809. * Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.
  2810. * @param {Object} element The DOMElement or NodeList to attach a listener.
  2811. * @param {String} eventName The event name to attach the observable sequence.
  2812. * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
  2813. * @returns {Observable} An observable sequence of events from the specified element and the specified event.
  2814. */
  2815. fromEvent<T>(element: EventTarget, eventName: string, selector?: (arguments: any[]) => T): Observable<T>;
  2816. /**
  2817. * Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.
  2818. * @param {Object} element The DOMElement or NodeList to attach a listener.
  2819. * @param {String} eventName The event name to attach the observable sequence.
  2820. * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
  2821. * @returns {Observable} An observable sequence of events from the specified element and the specified event.
  2822. */
  2823. fromEvent<T>(element: { on: (name: string, cb: (e: any) => any) => void; off: (name: string, cb: (e: any) => any) => void }, eventName: string, selector?: (arguments: any[]) => T): Observable<T>;
  2824. }
  2825. export interface ObservableStatic {
  2826. /**
  2827. * Creates an observable sequence from an event emitter via an addHandler/removeHandler pair.
  2828. * @param {Function} addHandler The function to add a handler to the emitter.
  2829. * @param {Function} [removeHandler] The optional function to remove a handler from an emitter.
  2830. * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
  2831. * @returns {Observable} An observable sequence which wraps an event from an event emitter
  2832. */
  2833. fromEventPattern<T>(addHandler: (handler: Function) => void, removeHandler: (handler: Function) => void, selector?: (arguments: any[]) => T): Observable<T>;
  2834. }
  2835. export interface ObservableStatic {
  2836. /**
  2837. * Invokes the asynchronous function, surfacing the result through an observable sequence.
  2838. * @param {Function} functionAsync Asynchronous function which returns a Promise to run.
  2839. * @returns {Observable} An observable sequence exposing the function's result value, or an exception.
  2840. */
  2841. startAsync<T>(functionAsync: () => IPromise<T>): Observable<T>;
  2842. }
  2843. export interface Observable<T> {
  2844. /**
  2845. * Pauses the underlying observable sequence based upon the observable sequence which yields true/false.
  2846. * @example
  2847. * var pauser = new Rx.Subject();
  2848. * var source = Rx.Observable.interval(100).pausable(pauser);
  2849. * @param {Observable} pauser The observable sequence used to pause the underlying sequence.
  2850. * @returns {Observable} The observable sequence which is paused based upon the pauser.
  2851. */
  2852. pausable(pauser?: Observable<boolean>): PausableObservable<T>;
  2853. }
  2854. export interface PausableObservable<T> extends Observable<T> {
  2855. pause(): void;
  2856. resume(): void;
  2857. }
  2858. export interface Observable<T> {
  2859. /**
  2860. * Pauses the underlying observable sequence based upon the observable sequence which yields true/false,
  2861. * and yields the values that were buffered while paused.
  2862. * @example
  2863. * var pauser = new Rx.Subject();
  2864. * var source = Rx.Observable.interval(100).pausableBuffered(pauser);
  2865. * @param {Observable} pauser The observable sequence used to pause the underlying sequence.
  2866. * @returns {Observable} The observable sequence which is paused based upon the pauser.
  2867. */
  2868. pausableBuffered(pauser?: Observable<boolean>): PausableObservable<T>;
  2869. }
  2870. export interface Observable<T> {
  2871. /**
  2872. * Attaches a controller to the observable sequence with the ability to queue.
  2873. * @example
  2874. * var source = Rx.Observable.interval(100).controlled();
  2875. * source.request(3); // Reads 3 values
  2876. * @param {bool} enableQueue truthy value to determine if values should be queued pending the next request
  2877. * @param {Scheduler} scheduler determines how the requests will be scheduled
  2878. * @returns {Observable} The observable sequence which only propagates values on request.
  2879. */
  2880. controlled(enableQueue?: boolean, scheduler?: IScheduler): ControlledObservable<T>;
  2881. }
  2882. export interface ControlledObservable<T> extends Observable<T> {
  2883. request(numberOfItems?: number): IDisposable;
  2884. }
  2885. export interface ControlledObservable<T> {
  2886. /**
  2887. * Attaches a stop and wait observable to the current observable.
  2888. * @returns {Observable} A stop and wait observable.
  2889. */
  2890. stopAndWait(): Observable<T>;
  2891. }
  2892. export interface ControlledObservable<T> {
  2893. /**
  2894. * Creates a sliding windowed observable based upon the window size.
  2895. * @param {Number} windowSize The number of items in the window
  2896. * @returns {Observable} A windowed observable based upon the window size.
  2897. */
  2898. windowed(windowSize: number): Observable<T>;
  2899. }
  2900. export interface Observable<T> {
  2901. /**
  2902. * Pipes the existing Observable sequence into a Node.js Stream.
  2903. * @param {Stream} dest The destination Node.js stream.
  2904. * @returns {Stream} The destination stream.
  2905. */
  2906. pipe<TDest>(dest: TDest): TDest;
  2907. // TODO: Add link to node.d.ts some where
  2908. }
  2909. /**
  2910. * Represents an object that is both an observable sequence as well as an observer.
  2911. * Each notification is broadcasted to all subscribed observers.
  2912. */
  2913. export interface ISubject<T> extends IObservable<T>, IObserver<T>, IDisposable {
  2914. hasObservers(): boolean;
  2915. }
  2916. export interface Subject<T> extends Observable<T>, Observer<T>, IDisposable {
  2917. hasObservers(): boolean;
  2918. /** Is this value disposed. */
  2919. isDisposed: boolean;
  2920. }
  2921. interface SubjectStatic {
  2922. /**
  2923. * Creates a subject.
  2924. */
  2925. new <T>(): Subject<T>;
  2926. /**
  2927. * Creates a subject from the specified observer and observable.
  2928. * @param {Observer} observer The observer used to send messages to the subject.
  2929. * @param {Observable} observable The observable used to subscribe to messages sent from the subject.
  2930. * @returns {Subject} Subject implemented using the given observer and observable.
  2931. */
  2932. create<T>(observer?: IObserver<T>, observable?: IObservable<T>): Subject<T>;
  2933. }
  2934. /**
  2935. * Represents an object that is both an observable sequence as well as an observer.
  2936. * Each notification is broadcasted to all subscribed observers.
  2937. */
  2938. export var Subject: SubjectStatic;
  2939. export interface ConnectableObservable<T> extends Observable<T> {
  2940. connect(): IDisposable;
  2941. refCount(): Observable<T>;
  2942. }
  2943. export interface Observable<T> {
  2944. /**
  2945. * Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
  2946. * subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's
  2947. * invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.
  2948. *
  2949. * @example
  2950. * 1 - res = source.multicast(observable);
  2951. * 2 - res = source.multicast(function () { return new Subject(); }, function (x) { return x; });
  2952. *
  2953. * @param {Function|Subject} subjectOrSubjectSelector
  2954. * Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function.
  2955. * Or:
  2956. * Subject to push source elements into.
  2957. *
  2958. * @param {Function} [selector] Optional selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. Specified only if <paramref name="subjectOrSubjectSelector" is a factory function.
  2959. * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
  2960. */
  2961. multicast(subject: ISubject<T> | (() => ISubject<T>)): ConnectableObservable<T>;
  2962. /**
  2963. * Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
  2964. * subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's
  2965. * invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.
  2966. *
  2967. * @example
  2968. * 1 - res = source.multicast(observable);
  2969. * 2 - res = source.multicast(function () { return new Subject(); }, function (x) { return x; });
  2970. *
  2971. * @param {Function|Subject} subjectOrSubjectSelector
  2972. * Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function.
  2973. * Or:
  2974. * Subject to push source elements into.
  2975. *
  2976. * @param {Function} [selector] Optional selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. Specified only if <paramref name="subjectOrSubjectSelector" is a factory function.
  2977. * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
  2978. */
  2979. multicast<TResult>(subjectSelector: ISubject<T> | (() => ISubject<T>), selector: (source: ConnectableObservable<T>) => Observable<T>): Observable<T>;
  2980. }
  2981. export interface Observable<T> {
  2982. /**
  2983. * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence.
  2984. * This operator is a specialization of Multicast using a regular Subject.
  2985. *
  2986. * @example
  2987. * var resres = source.publish();
  2988. * var res = source.publish(function (x) { return x; });
  2989. *
  2990. * @param {Function} [selector] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all notifications of the source from the time of the subscription on.
  2991. * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
  2992. */
  2993. publish(): ConnectableObservable<T>;
  2994. /**
  2995. * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence.
  2996. * This operator is a specialization of Multicast using a regular Subject.
  2997. *
  2998. * @example
  2999. * var resres = source.publish();
  3000. * var res = source.publish(function (x) { return x; });
  3001. *
  3002. * @param {Function} [selector] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all notifications of the source from the time of the subscription on.
  3003. * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
  3004. */
  3005. publish<TResult>(selector: (source: ConnectableObservable<T>) => Observable<TResult>): Observable<TResult>;
  3006. }
  3007. export interface Observable<T> {
  3008. /**
  3009. * Returns an observable sequence that shares a single subscription to the underlying sequence.
  3010. * This operator is a specialization of publish which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.
  3011. * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
  3012. */
  3013. share(): Observable<T>;
  3014. }
  3015. export interface Observable<T> {
  3016. /**
  3017. * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence containing only the last notification.
  3018. * This operator is a specialization of Multicast using a AsyncSubject.
  3019. *
  3020. * @example
  3021. * var res = source.publishLast();
  3022. * var res = source.publishLast(function (x) { return x; });
  3023. *
  3024. * @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will only receive the last notification of the source.
  3025. * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
  3026. */
  3027. publishLast(): ConnectableObservable<T>;
  3028. /**
  3029. * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence containing only the last notification.
  3030. * This operator is a specialization of Multicast using a AsyncSubject.
  3031. *
  3032. * @example
  3033. * var res = source.publishLast();
  3034. * var res = source.publishLast(function (x) { return x; });
  3035. *
  3036. * @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will only receive the last notification of the source.
  3037. * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
  3038. */
  3039. publishLast<TResult>(selector: (source: ConnectableObservable<T>) => Observable<TResult>): Observable<TResult>;
  3040. }
  3041. export interface Observable<T> {
  3042. /**
  3043. * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initialValue.
  3044. * This operator is a specialization of Multicast using a BehaviorSubject.
  3045. *
  3046. * @example
  3047. * var res = source.publishValue(42);
  3048. * var res = source.publishValue(function (x) { return x.select(function (y) { return y * y; }) }, 42);
  3049. *
  3050. * @param {Function} [selector] Optional selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive immediately receive the initial value, followed by all notifications of the source from the time of the subscription on.
  3051. * @param {Mixed} initialValue Initial value received by observers upon subscription.
  3052. * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
  3053. */
  3054. publishValue(initialValue: T): ConnectableObservable<T>;
  3055. /**
  3056. * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initialValue.
  3057. * This operator is a specialization of Multicast using a BehaviorSubject.
  3058. *
  3059. * @example
  3060. * var res = source.publishValue(42);
  3061. * var res = source.publishValue(function (x) { return x.select(function (y) { return y * y; }) }, 42);
  3062. *
  3063. * @param {Function} [selector] Optional selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive immediately receive the initial value, followed by all notifications of the source from the time of the subscription on.
  3064. * @param {Mixed} initialValue Initial value received by observers upon subscription.
  3065. * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
  3066. */
  3067. publishValue<TResult>(selector: (source: ConnectableObservable<T>) => Observable<TResult>, initialValue: T): Observable<TResult>;
  3068. }
  3069. export interface Observable<T> {
  3070. /**
  3071. * Returns an observable sequence that shares a single subscription to the underlying sequence and starts with an initialValue.
  3072. * This operator is a specialization of publishValue which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.
  3073. * @param {Mixed} initialValue Initial value received by observers upon subscription.
  3074. * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
  3075. */
  3076. shareValue(initialValue: T): Observable<T>;
  3077. }
  3078. export interface Observable<T> {
  3079. /**
  3080. * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer.
  3081. * This operator is a specialization of Multicast using a ReplaySubject.
  3082. *
  3083. * @example
  3084. * var res = source.replay(null, 3);
  3085. * var res = source.replay(null, 3, 500);
  3086. * var res = source.replay(null, 3, 500, scheduler);
  3087. * var res = source.replay(function (x) { return x.take(6).repeat(); }, 3, 500, scheduler);
  3088. *
  3089. * @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy.
  3090. * @param bufferSize [Optional] Maximum element count of the replay buffer.
  3091. * @param windowSize [Optional] Maximum time length of the replay buffer.
  3092. * @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on.
  3093. * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
  3094. */
  3095. replay(selector?: void, bufferSize?: number, window?: number, scheduler?: IScheduler): ConnectableObservable<T>; // hack to catch first omitted parameter
  3096. /**
  3097. * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer.
  3098. * This operator is a specialization of Multicast using a ReplaySubject.
  3099. *
  3100. * @example
  3101. * var res = source.replay(null, 3);
  3102. * var res = source.replay(null, 3, 500);
  3103. * var res = source.replay(null, 3, 500, scheduler);
  3104. * var res = source.replay(function (x) { return x.take(6).repeat(); }, 3, 500, scheduler);
  3105. *
  3106. * @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy.
  3107. * @param bufferSize [Optional] Maximum element count of the replay buffer.
  3108. * @param windowSize [Optional] Maximum time length of the replay buffer.
  3109. * @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on.
  3110. * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
  3111. */
  3112. replay(selector: (source: ConnectableObservable<T>) => Observable<T>, bufferSize?: number, window?: number, scheduler?: IScheduler): Observable<T>;
  3113. }
  3114. export interface Observable<T> {
  3115. /**
  3116. * Returns an observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer.
  3117. * This operator is a specialization of replay which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.
  3118. *
  3119. * @example
  3120. * var res = source.shareReplay(3);
  3121. * var res = source.shareReplay(3, 500);
  3122. * var res = source.shareReplay(3, 500, scheduler);
  3123. *
  3124. * @param bufferSize [Optional] Maximum element count of the replay buffer.
  3125. * @param window [Optional] Maximum time length of the replay buffer.
  3126. * @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on.
  3127. * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
  3128. */
  3129. shareReplay(bufferSize?: number, window?: number, scheduler?: IScheduler): Observable<T>;
  3130. }
  3131. export interface Observable<T> {
  3132. /**
  3133. * Returns an observable sequence that shares a single subscription to the underlying sequence. This observable sequence
  3134. * can be resubscribed to, even if all prior subscriptions have ended. (unlike `.publish().refCount()`)
  3135. * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source.
  3136. */
  3137. singleInstance(): Observable<T>;
  3138. }
  3139. export interface Observable<T> {
  3140. /**
  3141. * Correlates the elements of two sequences based on overlapping durations.
  3142. *
  3143. * @param {Observable} right The right observable sequence to join elements for.
  3144. * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap.
  3145. * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap.
  3146. * @param {Function} resultSelector A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences. The parameters passed to the function correspond with the elements from the left and right source sequences for which overlap occurs.
  3147. * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration.
  3148. */
  3149. join<TRight, TDurationLeft, TDurationRight, TResult>(
  3150. right: Observable<TRight>,
  3151. leftDurationSelector: (leftItem: T) => Observable<TDurationLeft>,
  3152. rightDurationSelector: (rightItem: TRight) => Observable<TDurationRight>,
  3153. resultSelector: (leftItem: T, rightItem: TRight) => TResult): Observable<TResult>;
  3154. }
  3155. export interface Observable<T> {
  3156. /**
  3157. * Correlates the elements of two sequences based on overlapping durations, and groups the results.
  3158. *
  3159. * @param {Observable} right The right observable sequence to join elements for.
  3160. * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap.
  3161. * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap.
  3162. * @param {Function} resultSelector A function invoked to compute a result element for any element of the left sequence with overlapping elements from the right observable sequence. The first parameter passed to the function is an element of the left sequence. The second parameter passed to the function is an observable sequence with elements from the right sequence that overlap with the left sequence's element.
  3163. * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration.
  3164. */
  3165. groupJoin<TRight, TDurationLeft, TDurationRight, TResult>(
  3166. right: Observable<TRight>,
  3167. leftDurationSelector: (leftItem: T) => Observable<TDurationLeft>,
  3168. rightDurationSelector: (rightItem: TRight) => Observable<TDurationRight>,
  3169. resultSelector: (leftItem: T, rightItem: Observable<TRight>) => TResult): Observable<TResult>;
  3170. }
  3171. export interface Observable<T> {
  3172. /**
  3173. * Projects each element of an observable sequence into zero or more buffers.
  3174. * @param {Mixed} bufferOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).
  3175. * @param {Function} [bufferClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.
  3176. * @returns {Observable} An observable sequence of windows.
  3177. */
  3178. buffer<TBufferOpening>(bufferOpenings: Observable<TBufferOpening>): Observable<T[]>;
  3179. /**
  3180. * Projects each element of an observable sequence into zero or more buffers.
  3181. * @param {Mixed} bufferOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).
  3182. * @param {Function} [bufferClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.
  3183. * @returns {Observable} An observable sequence of windows.
  3184. */
  3185. buffer<TBufferClosing>(bufferClosingSelector: () => Observable<TBufferClosing>): Observable<T[]>;
  3186. /**
  3187. * Projects each element of an observable sequence into zero or more buffers.
  3188. * @param {Mixed} bufferOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).
  3189. * @param {Function} [bufferClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.
  3190. * @returns {Observable} An observable sequence of windows.
  3191. */
  3192. buffer<TBufferOpening, TBufferClosing>(bufferOpenings: Observable<TBufferOpening>, bufferClosingSelector: () => Observable<TBufferClosing>): Observable<T[]>;
  3193. }
  3194. export interface Observable<T> {
  3195. /**
  3196. * Projects each element of an observable sequence into zero or more windows.
  3197. *
  3198. * @param {Mixed} windowOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).
  3199. * @param {Function} [windowClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.
  3200. * @returns {Observable} An observable sequence of windows.
  3201. */
  3202. window<TWindowOpening>(windowOpenings: Observable<TWindowOpening>): Observable<Observable<T>>;
  3203. /**
  3204. * Projects each element of an observable sequence into zero or more windows.
  3205. *
  3206. * @param {Mixed} windowOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).
  3207. * @param {Function} [windowClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.
  3208. * @returns {Observable} An observable sequence of windows.
  3209. */
  3210. window<TWindowClosing>(windowClosingSelector: () => Observable<TWindowClosing>): Observable<Observable<T>>;
  3211. /**
  3212. * Projects each element of an observable sequence into zero or more windows.
  3213. *
  3214. * @param {Mixed} windowOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).
  3215. * @param {Function} [windowClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.
  3216. * @returns {Observable} An observable sequence of windows.
  3217. */
  3218. window<TWindowOpening, TWindowClosing>(windowOpenings: Observable<TWindowOpening>, windowClosingSelector: () => Observable<TWindowClosing>): Observable<Observable<T>>;
  3219. }
  3220. export interface Observable<T> {
  3221. /**
  3222. * Returns a new observable that triggers on the second and subsequent triggerings of the input observable.
  3223. * The Nth triggering of the input observable passes the arguments from the N-1th and Nth triggering as a pair.
  3224. * The argument passed to the N-1th triggering is held in hidden internal state until the Nth triggering occurs.
  3225. * @returns {Observable} An observable that triggers on successive pairs of observations from the input observable as an array.
  3226. */
  3227. pairwise(): Observable<[T, T]>;
  3228. }
  3229. export interface Observable<T> {
  3230. /**
  3231. * Returns two observables which partition the observations of the source by the given function.
  3232. * The first will trigger observations for those values for which the predicate returns true.
  3233. * The second will trigger observations for those values where the predicate returns false.
  3234. * The predicate is executed once for each subscribed observer.
  3235. * Both also propagate all error observations arising from the source and each completes
  3236. * when the source completes.
  3237. * @param {Function} predicate
  3238. * The function to determine which output Observable will trigger a particular observation.
  3239. * @returns {Array}
  3240. * An array of observables. The first triggers when the predicate returns true,
  3241. * and the second triggers when the predicate returns false.
  3242. */
  3243. partition(predicate: _Predicate<T>, thisArg?: any): [Observable<T>, Observable<T>];
  3244. }
  3245. export interface Observable<T> {
  3246. /**
  3247. * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions.
  3248. * This operator allows for a fluent style of writing queries that use the same sequence multiple times.
  3249. *
  3250. * @param {Function} selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence.
  3251. * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
  3252. */
  3253. let<TResult>(selector: (source: Observable<T>) => Observable<TResult>): Observable<TResult>;
  3254. }
  3255. export interface ObservableStatic {
  3256. /**
  3257. * Determines whether an observable collection contains values.
  3258. *
  3259. * @example
  3260. * 1 - res = Rx.Observable.if(condition, obs1);
  3261. * 2 - res = Rx.Observable.if(condition, obs1, obs2);
  3262. * 3 - res = Rx.Observable.if(condition, obs1, scheduler);
  3263. * @param {Function} condition The condition which determines if the thenSource or elseSource will be run.
  3264. * @param {Observable} thenSource The observable sequence or Promise that will be run if the condition function returns true.
  3265. * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the condition function returns false. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler.
  3266. * @returns {Observable} An observable sequence which is either the thenSource or elseSource.
  3267. */
  3268. if<T>(condition: () => boolean, thenSource: ObservableOrPromise<T>, elseSourceOrScheduler?: ObservableOrPromise<T> | IScheduler): Observable<T>;
  3269. }
  3270. export interface ObservableStatic {
  3271. /**
  3272. * Concatenates the observable sequences obtained by running the specified result selector for each element in source.
  3273. * There is an alias for this method called 'forIn' for browsers <IE9
  3274. * @param {Array} sources An array of values to turn into an observable sequence.
  3275. * @param {Function} resultSelector A function to apply to each item in the sources array to turn it into an observable sequence.
  3276. * @returns {Observable} An observable sequence from the concatenated observable sequences.
  3277. */
  3278. for<T, TResult>(sources: T[], resultSelector: _Selector<T, TResult>, thisArg?: any): Observable<TResult>;
  3279. /**
  3280. * Concatenates the observable sequences obtained by running the specified result selector for each element in source.
  3281. * There is an alias for this method called 'forIn' for browsers <IE9
  3282. * @param {Array} sources An array of values to turn into an observable sequence.
  3283. * @param {Function} resultSelector A function to apply to each item in the sources array to turn it into an observable sequence.
  3284. * @returns {Observable} An observable sequence from the concatenated observable sequences.
  3285. */
  3286. forIn<T, TResult>(sources: T[], resultSelector: _Selector<T, TResult>, thisArg?: any): Observable<TResult>;
  3287. }
  3288. export interface ObservableStatic {
  3289. /**
  3290. * Repeats source as long as condition holds emulating a while loop.
  3291. * There is an alias for this method called 'whileDo' for browsers <IE9
  3292. *
  3293. * @param {Function} condition The condition which determines if the source will be repeated.
  3294. * @param {Observable} source The observable sequence that will be run if the condition function returns true.
  3295. * @returns {Observable} An observable sequence which is repeated as long as the condition holds.
  3296. */
  3297. while<T>(condition: () => boolean, source: ObservableOrPromise<T>): Observable<T>;
  3298. /**
  3299. * Repeats source as long as condition holds emulating a while loop.
  3300. * There is an alias for this method called 'whileDo' for browsers <IE9
  3301. *
  3302. * @param {Function} condition The condition which determines if the source will be repeated.
  3303. * @param {Observable} source The observable sequence that will be run if the condition function returns true.
  3304. * @returns {Observable} An observable sequence which is repeated as long as the condition holds.
  3305. */
  3306. whileDo<T>(condition: () => boolean, source: ObservableOrPromise<T>): Observable<T>;
  3307. }
  3308. export interface Observable<T> {
  3309. /**
  3310. * Repeats source as long as condition holds emulating a do while loop.
  3311. *
  3312. * @param {Function} condition The condition which determines if the source will be repeated.
  3313. * @param {Observable} source The observable sequence that will be run if the condition function returns true.
  3314. * @returns {Observable} An observable sequence which is repeated as long as the condition holds.
  3315. */
  3316. doWhile(condition: () => boolean): Observable<T>;
  3317. }
  3318. export interface ObservableStatic {
  3319. /**
  3320. * Uses selector to determine which source in sources to use.
  3321. * @param {Function} selector The function which extracts the value for to test in a case statement.
  3322. * @param {Array} sources A object which has keys which correspond to the case statement labels.
  3323. * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the sources are not matched. If this is not provided, it defaults to Rx.Observabe.empty with the specified scheduler.
  3324. *
  3325. * @returns {Observable} An observable sequence which is determined by a case statement.
  3326. */
  3327. case<T>(selector: () => string, sources: { [key: string]: ObservableOrPromise<T>; }, schedulerOrElseSource?: IScheduler | ObservableOrPromise<T>): Observable<T>;
  3328. /**
  3329. * Uses selector to determine which source in sources to use.
  3330. * @param {Function} selector The function which extracts the value for to test in a case statement.
  3331. * @param {Array} sources A object which has keys which correspond to the case statement labels.
  3332. * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the sources are not matched. If this is not provided, it defaults to Rx.Observabe.empty with the specified scheduler.
  3333. *
  3334. * @returns {Observable} An observable sequence which is determined by a case statement.
  3335. */
  3336. case<T>(selector: () => number, sources: { [key: number]: ObservableOrPromise<T>; }, schedulerOrElseSource?: IScheduler | ObservableOrPromise<T>): Observable<T>;
  3337. }
  3338. export interface Observable<T> {
  3339. /**
  3340. * Expands an observable sequence by recursively invoking selector.
  3341. *
  3342. * @param {Function} selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again.
  3343. * @param {Scheduler} [scheduler] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler.
  3344. * @returns {Observable} An observable sequence containing all the elements produced by the recursive expansion.
  3345. */
  3346. expand(selector: (item: T) => Observable<T>, scheduler?: IScheduler): Observable<T>;
  3347. }
  3348. export interface ObservableStatic {
  3349. /**
  3350. * Runs all observable sequences in parallel and collect their last elements.
  3351. *
  3352. * @example
  3353. * 1 - res = Rx.Observable.forkJoin([obs1, obs2]);
  3354. * 1 - res = Rx.Observable.forkJoin(obs1, obs2, ...);
  3355. * @returns {Observable} An observable sequence with an array collecting the last elements of all the input sequences.
  3356. */
  3357. forkJoin<T>(sources: ObservableOrPromise<T>[]): Observable<T[]>;
  3358. /**
  3359. * Runs all observable sequences in parallel and collect their last elements.
  3360. *
  3361. * @example
  3362. * 1 - res = Rx.Observable.forkJoin([obs1, obs2]);
  3363. * 1 - res = Rx.Observable.forkJoin(obs1, obs2, ...);
  3364. * @returns {Observable} An observable sequence with an array collecting the last elements of all the input sequences.
  3365. */
  3366. forkJoin<T>(...args: ObservableOrPromise<T>[]): Observable<T[]>;
  3367. }
  3368. export interface Observable<T> {
  3369. /**
  3370. * Runs two observable sequences in parallel and combines their last elemenets.
  3371. *
  3372. * @param {Observable} second Second observable sequence.
  3373. * @param {Function} resultSelector Result selector function to invoke with the last elements of both sequences.
  3374. * @returns {Observable} An observable sequence with the result of calling the selector function with the last elements of both input sequences.
  3375. */
  3376. forkJoin<TSecond, TResult>(second: ObservableOrPromise<TSecond>, resultSelector: (left: T, right: TSecond) => TResult): Observable<TResult>;
  3377. }
  3378. export interface Observable<T> {
  3379. /**
  3380. * Comonadic bind operator.
  3381. * @param {Function} selector A transform function to apply to each element.
  3382. * @param {Object} scheduler Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler.
  3383. * @returns {Observable} An observable sequence which results from the comonadic bind operation.
  3384. */
  3385. manySelect<TResult>(selector: _Selector<Observable<T>, TResult>, scheduler?: IScheduler): Observable<TResult>;
  3386. /**
  3387. * Comonadic bind operator.
  3388. * @param {Function} selector A transform function to apply to each element.
  3389. * @param {Object} scheduler Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler.
  3390. * @returns {Observable} An observable sequence which results from the comonadic bind operation.
  3391. */
  3392. extend<TResult>(selector: _Selector<Observable<T>, TResult>, scheduler?: IScheduler): Observable<TResult>;
  3393. }
  3394. export class Plan<T> { }
  3395. export interface Pattern2<T1, T2> {
  3396. /**
  3397. * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value.
  3398. * @param other Observable sequence to match in addition to the current pattern.
  3399. * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value.
  3400. */
  3401. and<T3>(other: Observable<T3>): Pattern3<T1, T2, T3>;
  3402. /**
  3403. * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values.
  3404. * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.
  3405. * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
  3406. */
  3407. thenDo<TR>(selector: (item1: T1, item2: T2) => TR): Plan<TR>;
  3408. }
  3409. interface Pattern3<T1, T2, T3> {
  3410. /**
  3411. * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value.
  3412. * @param other Observable sequence to match in addition to the current pattern.
  3413. * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value.
  3414. */
  3415. and<T4>(other: Observable<T4>): Pattern4<T1, T2, T3, T4>;
  3416. /**
  3417. * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values.
  3418. * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.
  3419. * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
  3420. */
  3421. thenDo<TR>(selector: (item1: T1, item2: T2, item3: T3) => TR): Plan<TR>;
  3422. }
  3423. interface Pattern4<T1, T2, T3, T4> {
  3424. /**
  3425. * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value.
  3426. * @param other Observable sequence to match in addition to the current pattern.
  3427. * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value.
  3428. */
  3429. and<T5>(other: Observable<T5>): Pattern5<T1, T2, T3, T4, T5>;
  3430. /**
  3431. * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values.
  3432. * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.
  3433. * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
  3434. */
  3435. thenDo<TR>(selector: (item1: T1, item2: T2, item3: T3, item4: T4) => TR): Plan<TR>;
  3436. }
  3437. interface Pattern5<T1, T2, T3, T4, T5> {
  3438. /**
  3439. * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value.
  3440. * @param other Observable sequence to match in addition to the current pattern.
  3441. * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value.
  3442. */
  3443. and<T6>(other: Observable<T6>): Pattern6<T1, T2, T3, T4, T5, T6>;
  3444. /**
  3445. * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values.
  3446. * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.
  3447. * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
  3448. */
  3449. thenDo<TR>(selector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5) => TR): Plan<TR>;
  3450. }
  3451. interface Pattern6<T1, T2, T3, T4, T5, T6> {
  3452. /**
  3453. * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value.
  3454. * @param other Observable sequence to match in addition to the current pattern.
  3455. * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value.
  3456. */
  3457. and<T7>(other: Observable<T7>): Pattern7<T1, T2, T3, T4, T5, T6, T7>;
  3458. /**
  3459. * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values.
  3460. * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.
  3461. * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
  3462. */
  3463. thenDo<TR>(selector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6) => TR): Plan<TR>;
  3464. }
  3465. interface Pattern7<T1, T2, T3, T4, T5, T6, T7> {
  3466. /**
  3467. * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value.
  3468. * @param other Observable sequence to match in addition to the current pattern.
  3469. * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value.
  3470. */
  3471. and<T8>(other: Observable<T8>): Pattern8<T1, T2, T3, T4, T5, T6, T7, T8>;
  3472. /**
  3473. * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values.
  3474. * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.
  3475. * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
  3476. */
  3477. thenDo<TR>(selector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6, item7: T7) => TR): Plan<TR>;
  3478. }
  3479. interface Pattern8<T1, T2, T3, T4, T5, T6, T7, T8> {
  3480. /**
  3481. * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value.
  3482. * @param other Observable sequence to match in addition to the current pattern.
  3483. * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value.
  3484. */
  3485. and<T9>(other: Observable<T9>): Pattern9<T1, T2, T3, T4, T5, T6, T7, T8, T9>;
  3486. /**
  3487. * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values.
  3488. * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.
  3489. * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
  3490. */
  3491. thenDo<TR>(selector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6, item7: T7, item8: T8) => TR): Plan<TR>;
  3492. }
  3493. interface Pattern9<T1, T2, T3, T4, T5, T6, T7, T8, T9> {
  3494. /**
  3495. * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values.
  3496. * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.
  3497. * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
  3498. */
  3499. thenDo<TR>(selector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6, item7: T7, item8: T8, item9: T9) => TR): Plan<TR>;
  3500. }
  3501. export interface Observable<T> {
  3502. /**
  3503. * Creates a pattern that matches when both observable sequences have an available value.
  3504. *
  3505. * @param right Observable sequence to match with the current sequence.
  3506. * @return {Pattern} Pattern object that matches when both observable sequences have an available value.
  3507. */
  3508. and<T2>(right: Observable<T2>): Pattern2<T, T2>;
  3509. }
  3510. export interface Observable<T> {
  3511. /**
  3512. * Matches when the observable sequence has an available value and projects the value.
  3513. *
  3514. * @param {Function} selector Selector that will be invoked for values in the source sequence.
  3515. * @returns {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
  3516. */
  3517. thenDo<TR>(selector: (item1: T) => TR): Plan<TR>;
  3518. }
  3519. export interface ObservableStatic {
  3520. /**
  3521. * Joins together the results from several patterns.
  3522. *
  3523. * @param plans A series of plans (specified as an Array of as a series of arguments) created by use of the Then operator on patterns.
  3524. * @returns {Observable} Observable sequence with the results form matching several patterns.
  3525. */
  3526. when<TR>(plan: Plan<TR>): Observable<TR>;
  3527. }
  3528. export interface ObservableStatic {
  3529. /**
  3530. * Returns an observable sequence that produces a value after each period.
  3531. *
  3532. * @example
  3533. * 1 - res = Rx.Observable.interval(1000);
  3534. * 2 - res = Rx.Observable.interval(1000, Rx.Scheduler.timeout);
  3535. *
  3536. * @param {Number} period Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds).
  3537. * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, Rx.Scheduler.timeout is used.
  3538. * @returns {Observable} An observable sequence that produces a value after each period.
  3539. */
  3540. interval(period: number, scheduler?: IScheduler): Observable<number>;
  3541. }
  3542. export interface ObservableStatic {
  3543. /**
  3544. * Returns an observable sequence that produces a value after dueTime has elapsed and then after each period.
  3545. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value.
  3546. * @param {Mixed} [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring.
  3547. * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used.
  3548. * @returns {Observable} An observable sequence that produces a value after due time has elapsed and then each period.
  3549. */
  3550. timer(dueTime: number, period: number, scheduler?: IScheduler): Observable<number>;
  3551. /**
  3552. * Returns an observable sequence that produces a value after dueTime has elapsed and then after each period.
  3553. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value.
  3554. * @param {Mixed} [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring.
  3555. * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used.
  3556. * @returns {Observable} An observable sequence that produces a value after due time has elapsed and then each period.
  3557. */
  3558. timer(dueTime: number, scheduler?: IScheduler): Observable<number>;
  3559. }
  3560. export interface Observable<T> {
  3561. /**
  3562. * Time shifts the observable sequence by dueTime. The relative time intervals between the values are preserved.
  3563. *
  3564. * @example
  3565. * 1 - res = Rx.Observable.delay(new Date());
  3566. * 2 - res = Rx.Observable.delay(new Date(), Rx.Scheduler.timeout);
  3567. *
  3568. * 3 - res = Rx.Observable.delay(5000);
  3569. * 4 - res = Rx.Observable.delay(5000, 1000, Rx.Scheduler.timeout);
  3570. * @memberOf Observable#
  3571. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence.
  3572. * @param {Scheduler} [scheduler] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used.
  3573. * @returns {Observable} Time-shifted sequence.
  3574. */
  3575. delay(dueTime: Date, scheduler?: IScheduler): Observable<T>;
  3576. /**
  3577. * Time shifts the observable sequence by dueTime. The relative time intervals between the values are preserved.
  3578. *
  3579. * @example
  3580. * 1 - res = Rx.Observable.delay(new Date());
  3581. * 2 - res = Rx.Observable.delay(new Date(), Rx.Scheduler.timeout);
  3582. *
  3583. * 3 - res = Rx.Observable.delay(5000);
  3584. * 4 - res = Rx.Observable.delay(5000, 1000, Rx.Scheduler.timeout);
  3585. * @memberOf Observable#
  3586. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence.
  3587. * @param {Scheduler} [scheduler] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used.
  3588. * @returns {Observable} Time-shifted sequence.
  3589. */
  3590. delay(dueTime: number, scheduler?: IScheduler): Observable<T>;
  3591. /**
  3592. * Time shifts the observable sequence based on a subscription delay and a delay selector function for each element.
  3593. *
  3594. * @example
  3595. * 1 - res = source.delayWithSelector(function (x) { return Rx.Scheduler.timer(5000); }); // with selector only
  3596. * 1 - res = source.delayWithSelector(Rx.Observable.timer(2000), function (x) { return Rx.Observable.timer(x); }); // with delay and selector
  3597. *
  3598. * @param {Observable} [subscriptionDelay] Sequence indicating the delay for the subscription to the source.
  3599. * @param {Function} delayDurationSelector Selector function to retrieve a sequence indicating the delay for each given element.
  3600. * @returns {Observable} Time-shifted sequence.
  3601. */
  3602. delay(delayDurationSelector: (item: T) => ObservableOrPromise<number>): Observable<T>;
  3603. /**
  3604. * Time shifts the observable sequence based on a subscription delay and a delay selector function for each element.
  3605. *
  3606. * @example
  3607. * 1 - res = source.delayWithSelector(function (x) { return Rx.Scheduler.timer(5000); }); // with selector only
  3608. * 1 - res = source.delayWithSelector(Rx.Observable.timer(2000), function (x) { return Rx.Observable.timer(x); }); // with delay and selector
  3609. *
  3610. * @param {Observable} [subscriptionDelay] Sequence indicating the delay for the subscription to the source.
  3611. * @param {Function} delayDurationSelector Selector function to retrieve a sequence indicating the delay for each given element.
  3612. * @returns {Observable} Time-shifted sequence.
  3613. */
  3614. delay(subscriptionDelay: Observable<number>, delayDurationSelector: (item: T) => ObservableOrPromise<number>): Observable<T>;
  3615. }
  3616. export interface Observable<T> {
  3617. /**
  3618. * Ignores values from an observable sequence which are followed by another value before dueTime.
  3619. * @param {Number} dueTime Duration of the debounce period for each value (specified as an integer denoting milliseconds).
  3620. * @param {Scheduler} [scheduler] Scheduler to run the debounce timers on. If not specified, the timeout scheduler is used.
  3621. * @returns {Observable} The debounced sequence.
  3622. */
  3623. debounce(dueTime: number, scheduler?: IScheduler): Observable<T>;
  3624. /**
  3625. * Ignores values from an observable sequence which are followed by another value within a computed throttle duration.
  3626. * @param {Function} durationSelector Selector function to retrieve a sequence indicating the throttle duration for each given element.
  3627. * @returns {Observable} The debounced sequence.
  3628. */
  3629. debounce(debounceDurationSelector: (item: T) => ObservableOrPromise<any>): Observable<T>;
  3630. }
  3631. export interface Observable<T> {
  3632. /**
  3633. * Projects each element of an observable sequence into zero or more windows which are produced based on timing information.
  3634. * @param {Number} timeSpan Length of each window (specified as an integer denoting milliseconds).
  3635. * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive windows (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent windows.
  3636. * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used.
  3637. * @returns {Observable} An observable sequence of windows.
  3638. */
  3639. windowWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable<Observable<T>>;
  3640. /**
  3641. * Projects each element of an observable sequence into zero or more windows which are produced based on timing information.
  3642. * @param {Number} timeSpan Length of each window (specified as an integer denoting milliseconds).
  3643. * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive windows (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent windows.
  3644. * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used.
  3645. * @returns {Observable} An observable sequence of windows.
  3646. */
  3647. windowWithTime(timeSpan: number, scheduler?: IScheduler): Observable<Observable<T>>;
  3648. }
  3649. export interface Observable<T> {
  3650. /**
  3651. * Projects each element of an observable sequence into a window that is completed when either it's full or a given amount of time has elapsed.
  3652. * @param {Number} timeSpan Maximum time length of a window.
  3653. * @param {Number} count Maximum element count of a window.
  3654. * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used.
  3655. * @returns {Observable} An observable sequence of windows.
  3656. */
  3657. windowWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable<Observable<T>>;
  3658. }
  3659. export interface Observable<T> {
  3660. /**
  3661. * Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.
  3662. * @param {Number} timeSpan Length of each buffer (specified as an integer denoting milliseconds).
  3663. * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive buffers (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent buffers.
  3664. * @param {Scheduler} [scheduler] Scheduler to run buffer timers on. If not specified, the timeout scheduler is used.
  3665. * @returns {Observable} An observable sequence of buffers.
  3666. */
  3667. bufferWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable<T[]>;
  3668. /**
  3669. * Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.
  3670. * @param {Number} timeSpan Length of each buffer (specified as an integer denoting milliseconds).
  3671. * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive buffers (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent buffers.
  3672. * @param {Scheduler} [scheduler] Scheduler to run buffer timers on. If not specified, the timeout scheduler is used.
  3673. * @returns {Observable} An observable sequence of buffers.
  3674. */
  3675. bufferWithTime(timeSpan: number, scheduler?: IScheduler): Observable<T[]>;
  3676. }
  3677. export interface Observable<T> {
  3678. /**
  3679. * Projects each element of an observable sequence into a buffer that is completed when either it's full or a given amount of time has elapsed.
  3680. * @param {Number} timeSpan Maximum time length of a buffer.
  3681. * @param {Number} count Maximum element count of a buffer.
  3682. * @param {Scheduler} [scheduler] Scheduler to run bufferin timers on. If not specified, the timeout scheduler is used.
  3683. * @returns {Observable} An observable sequence of buffers.
  3684. */
  3685. bufferWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable<T[]>;
  3686. }
  3687. export interface TimeInterval<T> {
  3688. value: T;
  3689. interval: number;
  3690. }
  3691. export interface Observable<T> {
  3692. /**
  3693. * Records the time interval between consecutive values in an observable sequence.
  3694. *
  3695. * @example
  3696. * 1 - res = source.timeInterval();
  3697. * 2 - res = source.timeInterval(Rx.Scheduler.timeout);
  3698. *
  3699. * @param [scheduler] Scheduler used to compute time intervals. If not specified, the timeout scheduler is used.
  3700. * @returns {Observable} An observable sequence with time interval information on values.
  3701. */
  3702. timeInterval(scheduler?: IScheduler): Observable<TimeInterval<T>>;
  3703. }
  3704. export interface Timestamp<T> {
  3705. value: T;
  3706. timestamp: number;
  3707. }
  3708. export interface Observable<T> {
  3709. /**
  3710. * Records the timestamp for each value in an observable sequence.
  3711. *
  3712. * @example
  3713. * 1 - res = source.timestamp(); // produces { value: x, timestamp: ts }
  3714. * 2 - res = source.timestamp(Rx.Scheduler.default);
  3715. *
  3716. * @param {Scheduler} [scheduler] Scheduler used to compute timestamps. If not specified, the default scheduler is used.
  3717. * @returns {Observable} An observable sequence with timestamp information on values.
  3718. */
  3719. timestamp(scheduler?: IScheduler): Observable<Timestamp<T>>;
  3720. }
  3721. export interface Observable<T> {
  3722. /**
  3723. * Samples the observable sequence at each interval.
  3724. *
  3725. * @example
  3726. * 1 - res = source.sample(sampleObservable); // Sampler tick sequence
  3727. * 2 - res = source.sample(5000); // 5 seconds
  3728. * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds
  3729. *
  3730. * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable.
  3731. * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.
  3732. * @returns {Observable} Sampled observable sequence.
  3733. */
  3734. sample(intervalOrSampler: number, scheduler?: IScheduler): Observable<T>;
  3735. /**
  3736. * Samples the observable sequence at each interval.
  3737. *
  3738. * @example
  3739. * 1 - res = source.sample(sampleObservable); // Sampler tick sequence
  3740. * 2 - res = source.sample(5000); // 5 seconds
  3741. * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds
  3742. *
  3743. * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable.
  3744. * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.
  3745. * @returns {Observable} Sampled observable sequence.
  3746. */
  3747. sample<TSample>(sampler: Observable<TSample>, scheduler?: IScheduler): Observable<T>;
  3748. /**
  3749. * Samples the observable sequence at each interval.
  3750. *
  3751. * @example
  3752. * 1 - res = source.sample(sampleObservable); // Sampler tick sequence
  3753. * 2 - res = source.sample(5000); // 5 seconds
  3754. * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds
  3755. *
  3756. * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable.
  3757. * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.
  3758. * @returns {Observable} Sampled observable sequence.
  3759. */
  3760. throttleLatest(interval: number, scheduler?: IScheduler): Observable<T>;
  3761. /**
  3762. * Samples the observable sequence at each interval.
  3763. *
  3764. * @example
  3765. * 1 - res = source.sample(sampleObservable); // Sampler tick sequence
  3766. * 2 - res = source.sample(5000); // 5 seconds
  3767. * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds
  3768. *
  3769. * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable.
  3770. * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.
  3771. * @returns {Observable} Sampled observable sequence.
  3772. */
  3773. throttleLatest<TSample>(sampler: Observable<TSample>, scheduler?: IScheduler): Observable<T>;
  3774. }
  3775. export interface Observable<T> {
  3776. /**
  3777. * Returns the source observable sequence or the other observable sequence if dueTime elapses.
  3778. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) when a timeout occurs.
  3779. * @param {Scheduler} [scheduler] Scheduler to run the timeout timers on. If not specified, the timeout scheduler is used.
  3780. * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
  3781. */
  3782. timeout(dueTime: Date, scheduler?: IScheduler): Observable<T>;
  3783. /**
  3784. * Returns the source observable sequence or the other observable sequence if dueTime elapses.
  3785. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) when a timeout occurs.
  3786. * @param {Observable} [other] Sequence to return in case of a timeout. If not specified, a timeout error throwing sequence will be used.
  3787. * @param {Scheduler} [scheduler] Scheduler to run the timeout timers on. If not specified, the timeout scheduler is used.
  3788. * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
  3789. */
  3790. timeout(dueTime: Date, other?: Observable<T>, scheduler?: IScheduler): Observable<T>;
  3791. /**
  3792. * Returns the source observable sequence or the other observable sequence if dueTime elapses.
  3793. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) when a timeout occurs.
  3794. * @param {Observable} [other] Sequence to return in case of a timeout. If not specified, a timeout error throwing sequence will be used.
  3795. * @param {Scheduler} [scheduler] Scheduler to run the timeout timers on. If not specified, the timeout scheduler is used.
  3796. * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
  3797. */
  3798. timeout(dueTime: number, scheduler?: IScheduler): Observable<T>;
  3799. /**
  3800. * Returns the source observable sequence or the other observable sequence if dueTime elapses.
  3801. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) when a timeout occurs.
  3802. * @param {Observable} [other] Sequence to return in case of a timeout. If not specified, a timeout error throwing sequence will be used.
  3803. * @param {Scheduler} [scheduler] Scheduler to run the timeout timers on. If not specified, the timeout scheduler is used.
  3804. * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
  3805. */
  3806. timeout(dueTime: number, other?: Observable<T>, scheduler?: IScheduler): Observable<T>;
  3807. /**
  3808. * Returns the source observable sequence, switching to the other observable sequence if a timeout is signaled.
  3809. * @param {Function} timeoutDurationSelector Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.
  3810. * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
  3811. */
  3812. timeout<TTimeout>(timeoutdurationSelector: (item: T) => Observable<TTimeout>): Observable<T>;
  3813. /**
  3814. * Returns the source observable sequence, switching to the other observable sequence if a timeout is signaled.
  3815. * @param {Function} timeoutDurationSelector Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.
  3816. * @param {Observable} other Sequence to return in case of a timeout. If not provided, this is set to Observable.throwException().
  3817. * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
  3818. */
  3819. timeout<TTimeout>(timeoutdurationSelector: (item: T) => Observable<TTimeout>, other: Observable<T>): Observable<T>;
  3820. /**
  3821. * Returns the source observable sequence, switching to the other observable sequence if a timeout is signaled.
  3822. * @param {Observable} [firstTimeout] Observable sequence that represents the timeout for the first element. If not provided, this defaults to Observable.never().
  3823. * @param {Function} timeoutDurationSelector Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.
  3824. * @param {Observable} [other] Sequence to return in case of a timeout. If not provided, this is set to Observable.throwException().
  3825. * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
  3826. */
  3827. timeout<TTimeout>(firstTimeout: Observable<TTimeout>, timeoutdurationSelector: (item: T) => Observable<TTimeout>, other?: Observable<T>): Observable<T>;
  3828. }
  3829. export interface ObservableStatic {
  3830. /**
  3831. * Generates an observable sequence by iterating a state from an initial state until the condition fails.
  3832. *
  3833. * @example
  3834. * res = source.generateWithAbsoluteTime(0,
  3835. * function (x) { return return true; },
  3836. * function (x) { return x + 1; },
  3837. * function (x) { return x; },
  3838. * function (x) { return new Date(); }
  3839. * });
  3840. *
  3841. * @param {Mixed} initialState Initial state.
  3842. * @param {Function} condition Condition to terminate generation (upon returning false).
  3843. * @param {Function} iterate Iteration step function.
  3844. * @param {Function} resultSelector Selector function for results produced in the sequence.
  3845. * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning Date values.
  3846. * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used.
  3847. * @returns {Observable} The generated sequence.
  3848. */
  3849. generateWithAbsoluteTime<TState, TResult>(
  3850. initialState: TState,
  3851. condition: (state: TState) => boolean,
  3852. iterate: (state: TState) => TState,
  3853. resultSelector: (state: TState) => TResult,
  3854. timeSelector: (state: TState) => Date,
  3855. scheduler?: IScheduler): Observable<TResult>;
  3856. }
  3857. export interface ObservableStatic {
  3858. /**
  3859. * Generates an observable sequence by iterating a state from an initial state until the condition fails.
  3860. *
  3861. * @example
  3862. * res = source.generateWithRelativeTime(0,
  3863. * function (x) { return return true; },
  3864. * function (x) { return x + 1; },
  3865. * function (x) { return x; },
  3866. * function (x) { return 500; }
  3867. * );
  3868. *
  3869. * @param {Mixed} initialState Initial state.
  3870. * @param {Function} condition Condition to terminate generation (upon returning false).
  3871. * @param {Function} iterate Iteration step function.
  3872. * @param {Function} resultSelector Selector function for results produced in the sequence.
  3873. * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning integer values denoting milliseconds.
  3874. * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used.
  3875. * @returns {Observable} The generated sequence.
  3876. */
  3877. generateWithRelativeTime<TState, TResult>(
  3878. initialState: TState,
  3879. condition: (state: TState) => boolean,
  3880. iterate: (state: TState) => TState,
  3881. resultSelector: (state: TState) => TResult,
  3882. timeSelector: (state: TState) => number,
  3883. scheduler?: IScheduler): Observable<TResult>;
  3884. }
  3885. export interface Observable<T> {
  3886. /**
  3887. * Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.
  3888. *
  3889. * @example
  3890. * 1 - res = source.delaySubscription(5000); // 5s
  3891. * 2 - res = source.delaySubscription(5000, Rx.Scheduler.default); // 5 seconds
  3892. *
  3893. * @param {Number} dueTime Relative or absolute time shift of the subscription.
  3894. * @param {Scheduler} [scheduler] Scheduler to run the subscription delay timer on. If not specified, the timeout scheduler is used.
  3895. * @returns {Observable} Time-shifted sequence.
  3896. */
  3897. delaySubscription(dueTime: number, scheduler?: IScheduler): Observable<T>;
  3898. }
  3899. export interface Observable<T> {
  3900. /**
  3901. * Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  3902. *
  3903. * 1 - res = source.skipLastWithTime(5000);
  3904. * 2 - res = source.skipLastWithTime(5000, scheduler);
  3905. *
  3906. * @description
  3907. * This operator accumulates a queue with a length enough to store elements received during the initial duration window.
  3908. * As more elements are received, elements older than the specified duration are taken from the queue and produced on the
  3909. * result sequence. This causes elements to be delayed with duration.
  3910. * @param {Number} duration Duration for skipping elements from the end of the sequence.
  3911. * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout
  3912. * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the end of the source sequence.
  3913. */
  3914. skipLastWithTime(duration: number, scheduler?: IScheduler): Observable<T>;
  3915. }
  3916. export interface Observable<T> {
  3917. /**
  3918. * Returns elements within the specified duration from the end of the observable source sequence, using the specified schedulers to run timers and to drain the collected elements.
  3919. * @description
  3920. * This operator accumulates a queue with a length enough to store elements received during the initial duration window.
  3921. * As more elements are received, elements older than the specified duration are taken from the queue and produced on the
  3922. * result sequence. This causes elements to be delayed with duration.
  3923. * @param {Number} duration Duration for taking elements from the end of the sequence.
  3924. * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
  3925. * @returns {Observable} An observable sequence with the elements taken during the specified duration from the end of the source sequence.
  3926. */
  3927. takeLastWithTime(duration: number, timerScheduler?: IScheduler, loopScheduler?: IScheduler): Observable<T>;
  3928. }
  3929. export interface Observable<T> {
  3930. /**
  3931. * Returns an array with the elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  3932. * @description
  3933. * This operator accumulates a queue with a length enough to store elements received during the initial duration window.
  3934. * As more elements are received, elements older than the specified duration are taken from the queue and produced on the
  3935. * result sequence. This causes elements to be delayed with duration.
  3936. * @param {Number} duration Duration for taking elements from the end of the sequence.
  3937. * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
  3938. * @returns {Observable} An observable sequence containing a single array with the elements taken during the specified duration from the end of the source sequence.
  3939. */
  3940. takeLastBufferWithTime(duration: number, scheduler?: IScheduler): Observable<T[]>;
  3941. }
  3942. export interface Observable<T> {
  3943. /**
  3944. * Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  3945. *
  3946. * @example
  3947. * 1 - res = source.takeWithTime(5000, [optional scheduler]);
  3948. * @description
  3949. * This operator accumulates a queue with a length enough to store elements received during the initial duration window.
  3950. * As more elements are received, elements older than the specified duration are taken from the queue and produced on the
  3951. * result sequence. This causes elements to be delayed with duration.
  3952. * @param {Number} duration Duration for taking elements from the start of the sequence.
  3953. * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
  3954. * @returns {Observable} An observable sequence with the elements taken during the specified duration from the start of the source sequence.
  3955. */
  3956. takeWithTime(duration: number, scheduler?: IScheduler): Observable<T>;
  3957. }
  3958. export interface Observable<T> {
  3959. /**
  3960. * Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  3961. *
  3962. * @example
  3963. * 1 - res = source.skipWithTime(5000, [optional scheduler]);
  3964. *
  3965. * @description
  3966. * Specifying a zero value for duration doesn't guarantee no elements will be dropped from the start of the source sequence.
  3967. * This is a side-effect of the asynchrony introduced by the scheduler, where the action that causes callbacks from the source sequence to be forwarded
  3968. * may not execute immediately, despite the zero due time.
  3969. *
  3970. * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the duration.
  3971. * @param {Number} duration Duration for skipping elements from the start of the sequence.
  3972. * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
  3973. * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the start of the source sequence.
  3974. */
  3975. skipWithTime(duration: number, scheduler?: IScheduler): Observable<T>;
  3976. }
  3977. export interface Observable<T> {
  3978. /**
  3979. * Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
  3980. * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time.
  3981. *
  3982. * @examples
  3983. * 1 - res = source.skipUntilWithTime(new Date(), [scheduler]);
  3984. * 2 - res = source.skipUntilWithTime(5000, [scheduler]);
  3985. * @param {Date|Number} startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped.
  3986. * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
  3987. * @returns {Observable} An observable sequence with the elements skipped until the specified start time.
  3988. */
  3989. skipUntilWithTime(startTime: Date, scheduler?: IScheduler): Observable<T>;
  3990. /**
  3991. * Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
  3992. * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time.
  3993. *
  3994. * @examples
  3995. * 1 - res = source.skipUntilWithTime(new Date(), [scheduler]);
  3996. * 2 - res = source.skipUntilWithTime(5000, [scheduler]);
  3997. * @param {Date|Number} startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped.
  3998. * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
  3999. * @returns {Observable} An observable sequence with the elements skipped until the specified start time.
  4000. */
  4001. skipUntilWithTime(duration: number, scheduler?: IScheduler): Observable<T>;
  4002. }
  4003. export interface Observable<T> {
  4004. /**
  4005. * Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
  4006. * @param {Number | Date} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately.
  4007. * @param {Scheduler} [scheduler] Scheduler to run the timer on.
  4008. * @returns {Observable} An observable sequence with the elements taken until the specified end time.
  4009. */
  4010. takeUntilWithTime(endTime: Date, scheduler?: IScheduler): Observable<T>;
  4011. /**
  4012. * Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
  4013. * @param {Number | Date} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately.
  4014. * @param {Scheduler} [scheduler] Scheduler to run the timer on.
  4015. * @returns {Observable} An observable sequence with the elements taken until the specified end time.
  4016. */
  4017. takeUntilWithTime(duration: number, scheduler?: IScheduler): Observable<T>;
  4018. }
  4019. export interface Observable<T> {
  4020. /**
  4021. * Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration.
  4022. * @param {Number} windowDuration time to wait before emitting another item after emitting the last item
  4023. * @param {Scheduler} [scheduler] the Scheduler to use internally to manage the timers that handle timeout for each item. If not provided, defaults to Scheduler.timeout.
  4024. * @returns {Observable} An Observable that performs the throttle operation.
  4025. */
  4026. throttle(windowDuration: number, scheduler?: IScheduler): Observable<T>;
  4027. }
  4028. export interface Observable<T> {
  4029. /**
  4030. * Executes a transducer to transform the observable sequence
  4031. * @param {Transducer} transducer A transducer to execute
  4032. * @returns {Observable} An Observable sequence containing the results from the transducer.
  4033. */
  4034. transduce(transducer: any): any;
  4035. //TODO: Setup transducer
  4036. }
  4037. export interface Observable<T> {
  4038. /**
  4039. * Performs a exclusive waiting for the first to finish before subscribing to another observable.
  4040. * Observables that come in between subscriptions will be dropped on the floor.
  4041. * @returns {Observable} A exclusive observable with only the results that happen when subscribed.
  4042. */
  4043. switchFirst(): T;
  4044. }
  4045. export interface Observable<T> {
  4046. /**
  4047. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  4048. * transforms an observable sequence of observable sequences into an observable sequence which performs a exclusive waiting for the first to finish before subscribing to another observable.
  4049. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  4050. * @param {Any} [thisArg] Object to use as this when executing callback.
  4051. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  4052. * and that at any point in time performs a exclusive waiting for the first to finish before subscribing to another observable.
  4053. */
  4054. selectSwitchFirst<TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TResult>>): Observable<TResult>;
  4055. /**
  4056. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  4057. * transforms an observable sequence of observable sequences into an observable sequence which performs a exclusive waiting for the first to finish before subscribing to another observable.
  4058. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  4059. * @param {Any} [thisArg] Object to use as this when executing callback.
  4060. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  4061. * and that at any point in time performs a exclusive waiting for the first to finish before subscribing to another observable.
  4062. */
  4063. selectSwitchFirst<TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TResult>>): Observable<TResult>;
  4064. /**
  4065. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  4066. * transforms an observable sequence of observable sequences into an observable sequence which performs a exclusive waiting for the first to finish before subscribing to another observable.
  4067. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  4068. * @param {Any} [thisArg] Object to use as this when executing callback.
  4069. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  4070. * and that at any point in time performs a exclusive waiting for the first to finish before subscribing to another observable.
  4071. */
  4072. selectSwitchFirst<TOther, TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  4073. /**
  4074. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  4075. * transforms an observable sequence of observable sequences into an observable sequence which performs a exclusive waiting for the first to finish before subscribing to another observable.
  4076. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  4077. * @param {Any} [thisArg] Object to use as this when executing callback.
  4078. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  4079. * and that at any point in time performs a exclusive waiting for the first to finish before subscribing to another observable.
  4080. */
  4081. selectSwitchFirst<TOther, TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  4082. /**
  4083. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  4084. * transforms an observable sequence of observable sequences into an observable sequence which performs a exclusive waiting for the first to finish before subscribing to another observable.
  4085. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  4086. * @param {Any} [thisArg] Object to use as this when executing callback.
  4087. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  4088. * and that at any point in time performs a exclusive waiting for the first to finish before subscribing to another observable.
  4089. */
  4090. flatMapFirst<TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TResult>>): Observable<TResult>;
  4091. /**
  4092. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  4093. * transforms an observable sequence of observable sequences into an observable sequence which performs a exclusive waiting for the first to finish before subscribing to another observable.
  4094. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  4095. * @param {Any} [thisArg] Object to use as this when executing callback.
  4096. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  4097. * and that at any point in time performs a exclusive waiting for the first to finish before subscribing to another observable.
  4098. */
  4099. flatMapFirst<TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TResult>>): Observable<TResult>;
  4100. /**
  4101. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  4102. * transforms an observable sequence of observable sequences into an observable sequence which performs a exclusive waiting for the first to finish before subscribing to another observable.
  4103. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  4104. * @param {Any} [thisArg] Object to use as this when executing callback.
  4105. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  4106. * and that at any point in time performs a exclusive waiting for the first to finish before subscribing to another observable.
  4107. */
  4108. flatMapFirst<TOther, TResult>(selector: _ValueOrSelector<T, ObservableOrPromise<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  4109. /**
  4110. * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
  4111. * transforms an observable sequence of observable sequences into an observable sequence which performs a exclusive waiting for the first to finish before subscribing to another observable.
  4112. * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
  4113. * @param {Any} [thisArg] Object to use as this when executing callback.
  4114. * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
  4115. * and that at any point in time performs a exclusive waiting for the first to finish before subscribing to another observable.
  4116. */
  4117. flatMapFirst<TOther, TResult>(selector: _ValueOrSelector<T, ArrayOrIterable<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  4118. }
  4119. export interface Observable<T> {
  4120. /**
  4121. * One of the Following:
  4122. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  4123. *
  4124. * @example
  4125. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); });
  4126. * Or:
  4127. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  4128. *
  4129. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  4130. * Or:
  4131. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  4132. *
  4133. * var res = source.flatMapWithMaxConcurrent(5, Rx.Observable.fromArray([1,2,3]));
  4134. * @param selector A transform function to apply to each element or an observable sequence to project each element from the
  4135. * source sequence onto which could be either an observable or Promise.
  4136. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  4137. * @param {Any} [thisArg] Object to use as this when executing callback.
  4138. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  4139. */
  4140. selectManyWithMaxConcurrent<TResult>(maxConcurrent: number, selector: _ValueOrSelector<T, ObservableOrPromise<TResult>>): Observable<TResult>;
  4141. /**
  4142. * One of the Following:
  4143. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  4144. *
  4145. * @example
  4146. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); });
  4147. * Or:
  4148. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  4149. *
  4150. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  4151. * Or:
  4152. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  4153. *
  4154. * var res = source.flatMapWithMaxConcurrent(5, Rx.Observable.fromArray([1,2,3]));
  4155. * @param selector A transform function to apply to each element or an observable sequence to project each element from the
  4156. * source sequence onto which could be either an observable or Promise.
  4157. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  4158. * @param {Any} [thisArg] Object to use as this when executing callback.
  4159. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  4160. */
  4161. selectManyWithMaxConcurrent<TResult>(maxConcurrent: number, selector: _ValueOrSelector<T, ArrayOrIterable<TResult>>): Observable<TResult>;
  4162. /**
  4163. * One of the Following:
  4164. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  4165. *
  4166. * @example
  4167. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); });
  4168. * Or:
  4169. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  4170. *
  4171. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  4172. * Or:
  4173. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  4174. *
  4175. * var res = source.flatMapWithMaxConcurrent(5, Rx.Observable.fromArray([1,2,3]));
  4176. * @param selector A transform function to apply to each element or an observable sequence to project each element from the
  4177. * source sequence onto which could be either an observable or Promise.
  4178. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  4179. * @param {Any} [thisArg] Object to use as this when executing callback.
  4180. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  4181. */
  4182. selectManyWithMaxConcurrent<TOther, TResult>(maxConcurrent: number, selector: _ValueOrSelector<T, ObservableOrPromise<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  4183. /**
  4184. * One of the Following:
  4185. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  4186. *
  4187. * @example
  4188. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); });
  4189. * Or:
  4190. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  4191. *
  4192. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  4193. * Or:
  4194. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  4195. *
  4196. * var res = source.flatMapWithMaxConcurrent(5, Rx.Observable.fromArray([1,2,3]));
  4197. * @param selector A transform function to apply to each element or an observable sequence to project each element from the
  4198. * source sequence onto which could be either an observable or Promise.
  4199. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  4200. * @param {Any} [thisArg] Object to use as this when executing callback.
  4201. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  4202. */
  4203. selectManyWithMaxConcurrent<TOther, TResult>(maxConcurrent: number, selector: _ValueOrSelector<T, ArrayOrIterable<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  4204. /**
  4205. * One of the Following:
  4206. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  4207. *
  4208. * @example
  4209. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); });
  4210. * Or:
  4211. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  4212. *
  4213. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  4214. * Or:
  4215. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  4216. *
  4217. * var res = source.flatMapWithMaxConcurrent(5, Rx.Observable.fromArray([1,2,3]));
  4218. * @param selector A transform function to apply to each element or an observable sequence to project each element from the
  4219. * source sequence onto which could be either an observable or Promise.
  4220. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  4221. * @param {Any} [thisArg] Object to use as this when executing callback.
  4222. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  4223. */
  4224. flatMapWithMaxConcurrent<TResult>(maxConcurrent: number, selector: _ValueOrSelector<T, ObservableOrPromise<TResult>>): Observable<TResult>;
  4225. /**
  4226. * One of the Following:
  4227. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  4228. *
  4229. * @example
  4230. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); });
  4231. * Or:
  4232. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  4233. *
  4234. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  4235. * Or:
  4236. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  4237. *
  4238. * var res = source.flatMapWithMaxConcurrent(5, Rx.Observable.fromArray([1,2,3]));
  4239. * @param selector A transform function to apply to each element or an observable sequence to project each element from the
  4240. * source sequence onto which could be either an observable or Promise.
  4241. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  4242. * @param {Any} [thisArg] Object to use as this when executing callback.
  4243. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  4244. */
  4245. flatMapWithMaxConcurrent<TResult>(maxConcurrent: number, selector: _ValueOrSelector<T, ArrayOrIterable<TResult>>): Observable<TResult>;
  4246. /**
  4247. * One of the Following:
  4248. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  4249. *
  4250. * @example
  4251. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); });
  4252. * Or:
  4253. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  4254. *
  4255. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  4256. * Or:
  4257. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  4258. *
  4259. * var res = source.flatMapWithMaxConcurrent(5, Rx.Observable.fromArray([1,2,3]));
  4260. * @param selector A transform function to apply to each element or an observable sequence to project each element from the
  4261. * source sequence onto which could be either an observable or Promise.
  4262. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  4263. * @param {Any} [thisArg] Object to use as this when executing callback.
  4264. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  4265. */
  4266. flatMapWithMaxConcurrent<TOther, TResult>(maxConcurrent: number, selector: _ValueOrSelector<T, ObservableOrPromise<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  4267. /**
  4268. * One of the Following:
  4269. * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  4270. *
  4271. * @example
  4272. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); });
  4273. * Or:
  4274. * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  4275. *
  4276. * var res = source.flatMapWithMaxConcurrent(5, function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
  4277. * Or:
  4278. * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  4279. *
  4280. * var res = source.flatMapWithMaxConcurrent(5, Rx.Observable.fromArray([1,2,3]));
  4281. * @param selector A transform function to apply to each element or an observable sequence to project each element from the
  4282. * source sequence onto which could be either an observable or Promise.
  4283. * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
  4284. * @param {Any} [thisArg] Object to use as this when executing callback.
  4285. * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
  4286. */
  4287. flatMapWithMaxConcurrent<TOther, TResult>(maxConcurrent: number, selector: _ValueOrSelector<T, ArrayOrIterable<TOther>>, resultSelector: special._FlatMapResultSelector<T, TOther, TResult>, thisArg?: any): Observable<TResult>;
  4288. }
  4289. export interface VirtualTimeScheduler<TAbsolute, TRelative> extends IScheduler {
  4290. /**
  4291. * Adds a relative time value to an absolute time value.
  4292. * @param {Number} absolute Absolute virtual time value.
  4293. * @param {Number} relative Relative virtual time value to add.
  4294. * @return {Number} Resulting absolute virtual time sum value.
  4295. */
  4296. add(from: TAbsolute, by: TRelative): TAbsolute;
  4297. /**
  4298. * Converts an absolute time to a number
  4299. * @param {Any} The absolute time.
  4300. * @returns {Number} The absolute time in ms
  4301. */
  4302. toAbsoluteTime(duetime: TAbsolute): number;
  4303. /**
  4304. * Converts the TimeSpan value to a relative virtual time value.
  4305. * @param {Number} timeSpan TimeSpan value to convert.
  4306. * @return {Number} Corresponding relative virtual time value.
  4307. */
  4308. toRelativeTime(duetime: number): TRelative;
  4309. /**
  4310. * Starts the virtual time scheduler.
  4311. */
  4312. start(): IDisposable;
  4313. /**
  4314. * Stops the virtual time scheduler.
  4315. */
  4316. stop(): void;
  4317. /**
  4318. * Advances the scheduler's clock to the specified time, running all work till that point.
  4319. * @param {Number} time Absolute time to advance the scheduler's clock to.
  4320. */
  4321. advanceTo(time: TAbsolute): void;
  4322. /**
  4323. * Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan.
  4324. * @param {Number} time Relative time to advance the scheduler's clock by.
  4325. */
  4326. advanceBy(time: TRelative): void;
  4327. /**
  4328. * Advances the scheduler's clock by the specified relative time.
  4329. * @param {Number} time Relative time to advance the scheduler's clock by.
  4330. */
  4331. sleep(time: TRelative): void;
  4332. isEnabled: boolean;
  4333. /**
  4334. * Gets the next scheduled item to be executed.
  4335. * @returns {ScheduledItem} The next scheduled item.
  4336. */
  4337. getNext(): internals.ScheduledItem<TAbsolute>;
  4338. }
  4339. export interface HistoricalScheduler extends VirtualTimeScheduler<number, number> {
  4340. }
  4341. export var HistoricalScheduler: {
  4342. /**
  4343. * Creates a new historical scheduler with the specified initial clock value.
  4344. * @constructor
  4345. * @param {Number} initialClock Initial value for the clock.
  4346. * @param {Function} comparer Comparer to determine causality of events based on absolute time.
  4347. */
  4348. new (initialClock: number, comparer: _Comparer<number, number>): HistoricalScheduler;
  4349. };
  4350. export interface Subscription {
  4351. /**
  4352. * Checks whether the given subscription is equal to the current instance.
  4353. * @param other Subscription object to check for equality.
  4354. * @returns {Boolean} true if both objects are equal; false otherwise.
  4355. */
  4356. equals(other: Subscription): boolean;
  4357. /**
  4358. * Returns a string representation of the current Subscription value.
  4359. * @returns {String} String representation of the current Subscription value.
  4360. */
  4361. toString(): string;
  4362. }
  4363. interface SubscriptionStatic {
  4364. /**
  4365. * Creates a new subscription object with the given virtual subscription and unsubscription time.
  4366. *
  4367. * @constructor
  4368. * @param {Number} subscribe Virtual time at which the subscription occurred.
  4369. * @param {Number} unsubscribe Virtual time at which the unsubscription occurred.
  4370. */
  4371. new (subscribeAt: number, unsubscribeAt?: number): Subscription;
  4372. }
  4373. export var Subscription: SubscriptionStatic;
  4374. export interface Recorded {
  4375. /**
  4376. * Checks whether the given recorded object is equal to the current instance.
  4377. *
  4378. * @param {Recorded} other Recorded object to check for equality.
  4379. * @returns {Boolean} true if both objects are equal; false otherwise.
  4380. */
  4381. equals(other: Recorded): boolean;
  4382. /**
  4383. * Returns a string representation of the current Recorded value.
  4384. *
  4385. * @returns {String} String representation of the current Recorded value.
  4386. */
  4387. toString(): string;
  4388. time: number;
  4389. value: any;
  4390. }
  4391. interface RecordedStatic {
  4392. /**
  4393. * Creates a new object recording the production of the specified value at the given virtual time.
  4394. *
  4395. * @constructor
  4396. * @param {Number} time Virtual time the value was produced on.
  4397. * @param {Mixed} value Value that was produced.
  4398. * @param {Function} comparer An optional comparer.
  4399. */
  4400. new (time: number, value: any, equalityComparer?: _Comparer<any, boolean>): Recorded;
  4401. }
  4402. export var Recorded: RecordedStatic;
  4403. export var ReactiveTest: {
  4404. /** Default virtual time used for creation of observable sequences in unit tests. */
  4405. created: number;
  4406. /** Default virtual time used to subscribe to observable sequences in unit tests. */
  4407. subscribed: number;
  4408. /** Default virtual time used to dispose subscriptions in unit tests. */
  4409. disposed: number;
  4410. /**
  4411. * Factory method for an OnNext notification record at a given time with a given value or a predicate function.
  4412. *
  4413. * 1 - ReactiveTest.onNext(200, 42);
  4414. * 2 - ReactiveTest.onNext(200, function (x) { return x.length == 2; });
  4415. *
  4416. * @param ticks Recorded virtual time the OnNext notification occurs.
  4417. * @param value Recorded value stored in the OnNext notification or a predicate.
  4418. * @return Recorded OnNext notification.
  4419. */
  4420. onNext(ticks: number, value: any): Recorded;
  4421. /**
  4422. * Factory method for an OnNext notification record at a given time with a given value or a predicate function.
  4423. *
  4424. * 1 - ReactiveTest.onNext(200, 42);
  4425. * 2 - ReactiveTest.onNext(200, function (x) { return x.length == 2; });
  4426. *
  4427. * @param ticks Recorded virtual time the OnNext notification occurs.
  4428. * @param value Recorded value stored in the OnNext notification or a predicate.
  4429. * @return Recorded OnNext notification.
  4430. */
  4431. onNext(ticks: number, predicate: (value: any) => boolean): Recorded;
  4432. /**
  4433. * Factory method for an OnError notification record at a given time with a given error.
  4434. *
  4435. * 1 - ReactiveTest.onNext(200, new Error('error'));
  4436. * 2 - ReactiveTest.onNext(200, function (e) { return e.message === 'error'; });
  4437. *
  4438. * @param ticks Recorded virtual time the OnError notification occurs.
  4439. * @param exception Recorded exception stored in the OnError notification.
  4440. * @return Recorded OnError notification.
  4441. */
  4442. onError(ticks: number, exception: any): Recorded;
  4443. /**
  4444. * Factory method for an OnError notification record at a given time with a given error.
  4445. *
  4446. * 1 - ReactiveTest.onNext(200, new Error('error'));
  4447. * 2 - ReactiveTest.onNext(200, function (e) { return e.message === 'error'; });
  4448. *
  4449. * @param ticks Recorded virtual time the OnError notification occurs.
  4450. * @param exception Recorded exception stored in the OnError notification.
  4451. * @return Recorded OnError notification.
  4452. */
  4453. onError(ticks: number, predicate: (exception: any) => boolean): Recorded;
  4454. /**
  4455. * Factory method for an OnCompleted notification record at a given time.
  4456. *
  4457. * @param ticks Recorded virtual time the OnCompleted notification occurs.
  4458. * @return Recorded OnCompleted notification.
  4459. */
  4460. onCompleted(ticks: number): Recorded;
  4461. /**
  4462. * Factory method for a subscription record based on a given subscription and disposal time.
  4463. *
  4464. * @param start Virtual time indicating when the subscription was created.
  4465. * @param end Virtual time indicating when the subscription was disposed.
  4466. * @return Subscription object.
  4467. */
  4468. subscribe(subscribeAt: number, unsubscribeAt?: number): Subscription;
  4469. }
  4470. export interface MockObserver<T> extends Observer<T> {
  4471. messages: Recorded[];
  4472. }
  4473. interface MockObserverStatic extends ObserverStatic {
  4474. new <T>(scheduler: IScheduler): MockObserver<T>;
  4475. }
  4476. export var MockObserver: MockObserverStatic;
  4477. export interface TestScheduler extends VirtualTimeScheduler<number, number> {
  4478. /**
  4479. * Creates a cold observable using the specified timestamped notification messages either as an array or arguments.
  4480. * @param messages Notifications to surface through the created sequence at their specified virtual time offsets from the sequence subscription time.
  4481. * @return Cold observable sequence that can be used to assert the timing of subscriptions and notifications.
  4482. */
  4483. createColdObservable<T>(...records: Recorded[]): Observable<T>;
  4484. /**
  4485. * Creates a hot observable using the specified timestamped notification messages either as an array or arguments.
  4486. * @param messages Notifications to surface through the created sequence at their specified absolute virtual times.
  4487. * @return Hot observable sequence that can be used to assert the timing of subscriptions and notifications.
  4488. */
  4489. createHotObservable<T>(...records: Recorded[]): Observable<T>;
  4490. /**
  4491. * Creates an observer that records received notification messages and timestamps those.
  4492. * @return Observer that can be used to assert the timing of received notifications.
  4493. */
  4494. createObserver<T>(): MockObserver<T>;
  4495. /**
  4496. * Creates a resolved promise with the given value and ticks
  4497. * @param {Number} ticks The absolute time of the resolution.
  4498. * @param {Any} value The value to yield at the given tick.
  4499. * @returns {MockPromise} A mock Promise which fulfills with the given value.
  4500. */
  4501. createResolvedPromise<T>(ticks: number, value: T): IPromise<T>;
  4502. /**
  4503. * Creates a rejected promise with the given reason and ticks
  4504. * @param {Number} ticks The absolute time of the resolution.
  4505. * @param {Any} reason The reason for rejection to yield at the given tick.
  4506. * @returns {MockPromise} A mock Promise which rejects with the given reason.
  4507. */
  4508. createRejectedPromise<T>(ticks: number, value: T): IPromise<T>;
  4509. /**
  4510. * Starts the test scheduler and uses the specified virtual times to invoke the factory function, subscribe to the resulting sequence, and dispose the subscription.
  4511. *
  4512. * @param create Factory method to create an observable sequence.
  4513. * @param created Virtual time at which to invoke the factory to create an observable sequence.
  4514. * @param subscribed Virtual time at which to subscribe to the created observable sequence.
  4515. * @param disposed Virtual time at which to dispose the subscription.
  4516. * @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active.
  4517. */
  4518. startWithTiming<T>(create: () => Observable<T>, createdAt: number, subscribedAt: number, disposedAt: number): MockObserver<T>;
  4519. /**
  4520. * Starts the test scheduler and uses the specified virtual time to dispose the subscription to the sequence obtained through the factory function.
  4521. * Default virtual times are used for factory invocation and sequence subscription.
  4522. *
  4523. * @param create Factory method to create an observable sequence.
  4524. * @param disposed Virtual time at which to dispose the subscription.
  4525. * @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active.
  4526. */
  4527. startWithDispose<T>(create: () => Observable<T>, disposedAt: number): MockObserver<T>;
  4528. /**
  4529. * Starts the test scheduler and uses default virtual times to invoke the factory function, to subscribe to the resulting sequence, and to dispose the subscription.
  4530. *
  4531. * @param create Factory method to create an observable sequence.
  4532. * @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active.
  4533. */
  4534. startWithCreate<T>(create: () => Observable<T>): MockObserver<T>;
  4535. }
  4536. export var TestScheduler: {
  4537. new (): TestScheduler;
  4538. }
  4539. export interface AnonymousObservable<T> extends Observable<T> { }
  4540. export interface GroupedObservable<TKey, TElement> extends Observable<TElement> {
  4541. key: TKey;
  4542. underlyingObservable: Observable<TElement>;
  4543. }
  4544. export interface AsyncSubject<T> extends Subject<T> { }
  4545. interface AsyncSubjectStatic {
  4546. /**
  4547. * Creates a subject that can only receive one value and that value is cached for all future observations.
  4548. * @constructor
  4549. */
  4550. new <T>(): AsyncSubject<T>;
  4551. }
  4552. /**
  4553. * Represents the result of an asynchronous operation.
  4554. * The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers.
  4555. */
  4556. export var AsyncSubject: AsyncSubjectStatic;
  4557. export interface BehaviorSubject<T> extends Subject<T> {
  4558. /**
  4559. * Gets the current value or throws an exception.
  4560. * Value is frozen after onCompleted is called.
  4561. * After onError is called always throws the specified exception.
  4562. * An exception is always thrown after dispose is called.
  4563. * @returns {Mixed} The initial value passed to the constructor until onNext is called; after which, the last value passed to onNext.
  4564. */
  4565. getValue(): T;
  4566. }
  4567. interface BehaviorSubjectStatic {
  4568. /**
  4569. * Initializes a new instance of the BehaviorSubject class which creates a subject that caches its last value and starts with the specified value.
  4570. * @param {Mixed} value Initial value sent to observers when no other value has been received by the subject yet.
  4571. */
  4572. new <T>(initialValue: T): BehaviorSubject<T>;
  4573. }
  4574. /**
  4575. * Represents a value that changes over time.
  4576. * Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications.
  4577. */
  4578. export var BehaviorSubject: BehaviorSubjectStatic;
  4579. export interface ReplaySubject<T> extends Subject<T> { }
  4580. interface ReplaySubjectStatic {
  4581. /**
  4582. * Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler.
  4583. * @param {Number} [bufferSize] Maximum element count of the replay buffer.
  4584. * @param {Number} [windowSize] Maximum time length of the replay buffer.
  4585. * @param {Scheduler} [scheduler] Scheduler the observers are invoked on.
  4586. */
  4587. new <T>(bufferSize?: number, window?: number, scheduler?: IScheduler): ReplaySubject<T>;
  4588. }
  4589. /**
  4590. * Represents an object that is both an observable sequence as well as an observer.
  4591. * Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.
  4592. */
  4593. export var ReplaySubject: ReplaySubjectStatic;
  4594. export interface AnonymousSubject<T> extends Subject<T> { }
  4595. interface AnonymousSubjectStatic {
  4596. /**
  4597. * Creates a subject that can only receive one value and that value is cached for all future observations.
  4598. * @constructor
  4599. */
  4600. new <T>(): AnonymousSubject<T>;
  4601. }
  4602. /**
  4603. * Represents the result of an asynchronous operation.
  4604. * The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers.
  4605. */
  4606. export var AnonymousSubject: AnonymousSubjectStatic;
  4607. /**
  4608. * Used to pause and resume streams.
  4609. */
  4610. export interface Pauser {
  4611. /**
  4612. * Pauses the underlying sequence.
  4613. */
  4614. pause(): void;
  4615. /**
  4616. * Resumes the underlying sequence.
  4617. */
  4618. resume(): void;
  4619. }
  4620. }
  4621. declare module "rx" { export = Rx; }
  4622. declare module "rx.all" { export = Rx; }