我有一个异步模板绑定,例如:
zipObs$
在我的代码中,let a$: AsyncSubject<any>, b$: AsyncSubject<any>;
// ... init a$ and b$
let zipObs$ = Observable.zip(a$, b$);
派生于一系列初始承诺,例如为方便起见,将可观察量组合成单个function poll() {
let current$ = getSomeObservable();
let next$ = current.delay(5000).concatMap(poll);
return Observable.merge(current$, next$);
}
this.polling$ = zipObs$.concatMap(poll);
:
Observable.zip
到目前为止,一切都很好。这就是轮询逻辑的样子(对此不太确定......):
private _sub: Subscripton;
// ... constructor or ngOnInit
let a$: AsyncSubject<any>, b$: AsyncSubject<any>;
// ... init a$ and b$
let zipObs$ = Observable.create(obs => {
this._sub = Observable.zip(a$, b$).subscribe([a,b] => obs.next([a,b]))
});
// ...
ngOnDestroy() { this._sub.unsubscribe(); }
它有点像预期的那样工作,唯一的问题是当组件被销毁时轮询不会停止,即角度似乎无法自动取消订阅所有可观察量。我设法通过跟踪<! DOCTYPE html>
<Html>
<Head>
<script language="vbscript" type="text/vbscript">
Sub Sample ()
Dim iRow
Set objExcel = CreateObject ("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open ("C:\Users\ARPIT SHAJU\Desktop\Church\Member.xlsx")
objExcel.Application.Visible = True
ObjWorkbook.Windows (1).Visible = True
Set XlSheet =objWorkbook.Sheets (1)
XlSheet.Activate
iRow = 1
With objExcel
Do while .Cells (iRow, 1).value <> ""
.Cells (iRow, 1).activate
iRow = iRow + 1
Loop
.Cells (iRow, 1).value=Document.GetElementsByName ("fname") (0).Value
.Cells (iRow, 2).value=Document.GetElementsByName ("surname") (0).Value
.Cells (iRow, 3).value=Document.GetElementsByName ("gender") (0).Value
.Cells (iRow, 4).value=Document.GetElementsByName ("mstatus") (0).Value
.Cells (iRow, 5).value=Document.GetElementsByName ("dob") (0).Value
.Cells (iRow, 6).value=Document.GetElementsByName ("doa") (0).Value
.Cells (iRow, 7).value=Document.GetElementsByName ("baptised") (0).Value
.Cells (iRow, 8).value=Document.GetElementsByName ("residence") (0).Value
.Cells (iRow, 9).value=Document.GetElementsByName ("mnumber") (0).Value
MsgBox "Data Added Successfully”, vbinformation
Document.GetElementsByName ("fname") (0).Value=""
Document.GetElementsByName ("surname") (0).Value=""
Document.GetElementsByName ("gender") (0).Value=""
Document.GetElementsByName ("mstatus") (0).Value=""
Document.GetElementsByName ("dob") (0).Value=""
Document.GetElementsByName ("doa") (0).Value=""
Document.GetElementsByName ("baptised") (0).Value=""
Document.GetElementsByName ("residence") (0).Value=""
Document.GetElementsByName ("mnumber") (0).Value=""
End With
ObjWorkbook. Save
ObjWorkbook. Close
Set objWorkbook = Nothing
Set objExcel = Nothing
End Sub
</script>
<style type="text/css">
fieldset {
border: #00cc00 2px solid;
padding: 10px;
color: green;
</style>
<body
<form>
<fieldset>
<legend>Csharpcorner</legend>
<center>
First name:<br>
<input type="text" name="fname" Value=""><br>
Surname:<br>
<input type="text" name="surname" Value=""><br>
Gender :<br>
<input type="text" name="gender" Value=""><br>
Marital Status :<br>
<input type="text" name="mstatus" Value=""><br>
Date of Birth :<br>
<input type="text" name="dob" Value=""><br>
<br>
Marriage Date :<br>
<input type="text" name="doa" Value=""><br>
Baptised :<br>
<input type="text" name="baptised" Value=""><br>
Residence :<br>
<input type="text" name="residence" Value=""><br>
Mobile Number :<br>
<input type="text" name="mnumber" Value=""><br>
<input type="button" onclick="Sample()" value="Submit"><br>
</center>
</fieldset>
<form>
</body>
</html>
订阅并手动取消订阅destroy来解决该问题:
.children()
现在它会在组件被销毁时停止轮询,但我无法确定是什么阻止角度单独完成。我怀疑是因为静态操作符,但我不确定。你能告诉我为什么会这样吗?
我们仍在使用棱角4.4.4
编辑:无法重现https://jsfiddle.net/RFontana/q6xwzhbk/:思考面孔: