在我的程序中,我有一个方法可以返回MyClass
或Observable.of(null)
的可观察对象。
代码如下:
doSomething(someParams) {
return this.backEnd.getStuff(someParams)
.switchMap(data => {
if (!data ) {
return Observable.of(null);
} else {
this.doSomethingElse(data);
}
});
}
其中doSomethingElse()返回Observable<MyClass>
。
如果我按上述方法编写方法,我会松开智能感知,因为我的IDE(VSCode)告诉我方法doSomething()返回一个Observable。
在这种情况下,有没有办法保持智能感知?我想要的是IDE建议我doSomething()方法返回一个Observable<MyClass>
并自然地进行逻辑检查,实际上有一个MyClass
或null
的实例。结果已订阅。
答案 0 :(得分:1)
您可以在spXML
'Gender','''/CreateAndSendMessageRequest/CompositionRequest/PolicyDetails
/MainPolicyHolder/PolicyHolderDetails'''
ALTER PROCEDURE spXML
@lasttag VARCHAR(50),
@root VARCHAR(MAX)
AS
BEGIN
Declare @xml xml
Set @xml = '<?xml version="1.0" encoding="utf-8"?>
<CreateAndSendMessageRequest>
<CompositionRequest>
<Metadata>
<PolicyReference>250028766622DN</PolicyReference>
<AccountReference>Test1234</AccountReference>
<QuoteReference>Test3214</QuoteReference>
<OutboundTransactionID>string</OutboundTransactionID>
<InboundActivityID>string</InboundActivityID>
<DocumentName>DocumentA127</DocumentName>
<DocumentID />
<CommunicationID>C004</CommunicationID>
<CorrelationID>PC: 20c14f9b-2a1b-45dc-b680-52ffceb86d05</CorrelationID>
<ContentType>string</ContentType>
<isSensitive>true</isSensitive>
<isReadOnly>true</isReadOnly>
<isDocumentInbound>true</isDocumentInbound>
<ChannelIdentifier>POST</ChannelIdentifier>
<BrandType>string</BrandType>
<SchemeNameCode>string</SchemeNameCode>
<isNotificationRequiredIndicator>false</isNotificationRequiredIndicator>
<DocumentPriorityIndicator>Standard</DocumentPriorityIndicator>
<SpecialInstructions>
<Code>string</Code>
<Description>string</Description>
</SpecialInstructions>
<SupressIndicator>false</SupressIndicator>
<OutsortIndicator>string</OutsortIndicator>
<DocumentIncludes>
<DocumentId DocumentTitle="string">string</DocumentId>
</DocumentIncludes>
<CreatedBy>string</CreatedBy>
<UpdatedBy>string</UpdatedBy>
<FulfilledDateTime>2017-05-15T07:41:13</FulfilledDateTime>
<UploadedDateTime>2013-12-21T17:02:42+05:30</UploadedDateTime>
<RequestDateTime>2016-01-01T19:07:42</RequestDateTime>
<UpdateDateTime>2012-01-07T19:42:56</UpdateDateTime>
</Metadata>
<PolicyDetails>
<PolicyReference>string</PolicyReference>
<QuoteReference>string</QuoteReference>
<PolicyVersionStartDate>2009-11-03</PolicyVersionStartDate>
<MainPolicyHolder>
<PolicyHolderDetails>
<Title>string</Title>
<Initials>string</Initials>
<Honours>string</Honours>
<Firstname>string</Firstname>
<Surname>string</Surname>
<FullName>string</FullName>
<Gender>F</Gender>
<DateOfBirth>2018-04-13</DateOfBirth>
</PolicyHolderDetails>
</PolicyDetails>
</CompositionRequest>
<VersionInfo majorVersion="1" minorVersion="19" />
</CreateAndSendMessageRequest>'
Declare @tag varchar(max)
set @tag = 'Select X.T.value(''('+@lasttag+')[1]'',''varchar(50)'') as Result
From @xml.nodes('+@root+') as X(T)'
print @tag
Execute(@tag)
End
为union type的Observable<MyClass | null>
处输入您的退货类型:
MyClass | null