在网上搜索后,我看到人们通常使用一种或另一种,而不是两者都使用。可以同时使用吗?这是好还是坏的做法?
编辑
我不是在问 take(1) 或 takeUntil 是干什么用的。相反,我在问是否有可能同时具有 take(1) 和 takeUntil 的效果。我知道 take(1) 将只取第一个值并结束订阅。但是,如果我从未收到该事件,它不会结束订阅。我也明白,只要我在销毁中触发 unsubscribeSubject,当组件不再活动时,这种 takeUntil 的使用将始终清除订阅。但是,它不会在我收到第一个值后释放该订阅,并且会在组件处于活动状态的整个时间内存在。
我想要的是一种在第一个值之后释放订阅的方法,并在未收到值时组件不再处于活动状态时防止内存泄漏。特别是在您有很多订阅的情况下。这是因为当您有很多订阅时,当不再需要该组件时,拥有一个可以清理所有订阅的主题会很方便。
ngAfterViewInit(){
//if first value comes, we process it and unsubscribe
this.myService.GetOneTimeObservable()
.pipe(take(1))
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(this.fooOT.bind(this))
//other subscriptions (assume many)
this.myService.GetLongLifeObservable1()
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(this.foo1.bind(this))
this.myService.GetLongLifeObservable2()
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(this.foo2.bind(this))
this.myService.GetLongLifeObservable3()
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(this.foo3.bind(this))
}
ngOnDestroy(){
//Ideally cleans all subscriptions, including the OneTime if no value is received
this.unsubscribeSubject.next();
this.unsubscribeSubject.complete();
}
Run Code Online (Sandbox Code Playgroud) 您知道如何使 ChromiumBrowser 打开时浏览器大小适合内容吗?现在这个 xaml 位于窗口主体中。当有人单击 MyTextBox 的文本时,ChromiumBrowser 将打开以显示更多信息。
编辑: 如果没有固定的宽度和高度,铬窗口不会显示。
....
<Canvas Panel.ZIndex="99" Visibility="{Binding IsChromiuimVisible, Converter={StaticResource BooleanToVisibilityConverter}, FallbackValue=Collapsed}">
<Popup Placement="Top" PlacementTarget="{Binding ElementName=MyTextBlock}"
IsOpen="{Binding IsChromiumVisible}" PopupAnimation="Fade" AllowsTransparency="True"
MouseEnter="OnMouseEnter" MouseLeave="OnMouseLeave">
<Grid Background="Transparent">
<cefSharp:ChromiumWebBrowser
Width="300" Height="620"
Address="{Binding ChromiumAddress, Mode=TwoWay}">
</cefSharp:ChromiumWebBrowser>
</Grid>
</Popup>
</Canvas>
....
Run Code Online (Sandbox Code Playgroud) 我目前正在尝试在 gradle 中为共享构建服务器运行一些测试。我收到以下错误:
Error occurred during initialization of VM
java.lang.InternalError: Could not create SecurityManager:
worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager
at sun.misc.Launcher.<init>(Launcher.java:102)
at sun.misc.Launcher.<clinit>(Launcher.java:53)
at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1451)
at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1436)
Run Code Online (Sandbox Code Playgroud)
使用 --debug 运行的 JVM 命令行参数是:
-DisTestMode=true
-Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager
-DtestLocators
-javaagent:../expandedArchives/org.jacoco.agent-0.7.8.jar_cbks496gfbgpke4b5ek12xen8/jacocoagent.jar=destfile=../../jacoco/testSpringContext_cnt_dmabtec.exec,append=true,inclnolocationclasses=false,dumponexit=true,output=file,jmx=false
-Xms128m
-Dfile.encoding=US-ASCII
-Duser.country=US
-Duser.language=en
-Duser.variant
Run Code Online (Sandbox Code Playgroud)
我尝试在本地和服务器上运行不同版本的 gradle 进行比较:
本地 2.14.1 与服务器
上的2.14.1 本地4.10.1 与服务器上的 4.5.x
有没有人对问题有什么想法?如果您需要更多信息,请询问,如果可以,我会提供。谢谢。
我正在尝试为 MS SQL Server 2014 的 db 部署设置 liquibase。当我尝试运行更新(使用命令行)时,我收到以下错误消息:
Unexpected error running Liquibase: liquibase.exception.DatabaseException: Connection could not be created to "jdbc:sqlserver://myserver:1234;databaseName=mydb" with driver com.microsoft.sqlserver.jdbc.SQLServerDriver. Possibly the wrong driver for the given database URL
Run Code Online (Sandbox Code Playgroud)
我的属性文件是:
classpath=D:\\Tools\\Liquibase\\Microsoft JDBC Driver 6.2 for SQL Server\\sqljdbc_6.2\\enu\\mssql-jdbc-6.2.2.jre8.jar
driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
url="jdbc:sqlserver://myserver:1234;databaseName=mydb"
username=MyUserName
password=SomePassword
changeLogFile=D:\\Tools\\Liquibase\\Test.sql
Run Code Online (Sandbox Code Playgroud)
liquibase 批处理文件在以下环境中运行:
Windows Server 2012
Java 1.8.0_31
Run Code Online (Sandbox Code Playgroud)
我还使用 Microsoft 的 JDBC 示例代码测试了连接。我将 mssql-jdbc-6.2.2.jre8.jar 添加到我的项目中,并使用属性文件中的相同 url、用户名、databaseName 和密码成功运行了查询。
String connectionUrl = "jdbc:sqlserver://myserver:1234;databaseName=mydb;user=MyUserName;password=SomePassword";
Run Code Online (Sandbox Code Playgroud)
我确信我有正确的驱动程序并且可以建立连接。但是,我无法弄清楚出了什么问题。
调试日志:
SEVERE 3/1/18 1:54 PM: liquibase: liquibase.exception.DatabaseException: Connection could not be …Run Code Online (Sandbox Code Playgroud)