This commit is contained in:
shikong 2024-04-30 16:46:27 +08:00
parent 949c1ee51a
commit 8dbf5293ba
4 changed files with 79 additions and 2 deletions

15
.idea/git_toolbox_prj.xml Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxProjectSettings">
<option name="commitMessageIssueKeyValidationOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
<option name="commitMessageValidationEnabledOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>logback</contextName>
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<!--<property name="log.path" value="./log/business_Log" />-->
<!--输出到控制台-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<!-- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">-->
<!-- <level>INFO</level>-->
<!-- </filter>-->
<!-- <withJansi>true</withJansi>-->
<encoder>
<!--<pattern>%d %p (%file:%line\)- %m%n</pattern>-->
<!--格式化输出:%d:表示日期 %thread:表示线程名 %-5level:级别从左显示5个字符宽度 %msg:日志消息 %n:是换行符-->
<pattern>%red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%thread]) %highlight(%-5level) %yellow(at %class.%method) (%file:%line\) - %cyan(%msg%n)</pattern>
<!--<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %magenta(%-5level) %green([%-50.50class]) >>> %cyan(%msg) %n</pattern>-->
<charset>UTF-8</charset>
</encoder>
</appender>
<!--&lt;!&ndash;输出到文件&ndash;&gt;-->
<!--<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
<!-- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">-->
<!-- <level>INFO</level>-->
<!-- </filter>-->
<!-- <file>${log.path}/logback.log</file>-->
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
<!-- <fileNamePattern>${log.path}/logback-%d{yyyy-MM-dd-HH-mm}.log</fileNamePattern>-->
<!-- <maxHistory>365</maxHistory>-->
<!-- &lt;!&ndash; <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">&ndash;&gt;-->
<!-- &lt;!&ndash; <maxFileSize>100kB</maxFileSize>&ndash;&gt;-->
<!-- &lt;!&ndash; </timeBasedFileNamingAndTriggeringPolicy>&ndash;&gt;-->
<!-- </rollingPolicy>-->
<!-- <encoder>-->
<!-- &lt;!&ndash;格式化输出:%d:表示日期 %thread:表示线程名 %-5level:级别从左显示5个字符宽度 %msg:日志消息 %n:是换行符&ndash;&gt;-->
<!-- <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>-->
<!-- <charset>UTF-8</charset>-->
<!-- </encoder>-->
<!--</appender>-->
<!-- 如果appender里没有限定日志级别那么root可以统一设置如果没有配置那么控制台和文件不会输出任何日志这里root的level不做限制-->
<root level="INFO">
<!-- 允许控制台输出-->
<appender-ref ref="console" />
<!--&lt;!&ndash; 允许文件输出&ndash;&gt;-->
<!--<appender-ref ref="file" />-->
</root>
<logger name="cn.skcks.study.rxjava" level="DEBUG" />
</configuration>

View File

@ -21,12 +21,15 @@ public class RxJavaStudyStarterTest {
Observable<Integer> integerObservable = Observable.create((ObservableOnSubscribe<Integer>) emitter -> { Observable<Integer> integerObservable = Observable.create((ObservableOnSubscribe<Integer>) emitter -> {
for (int i = 1; i <= 5; i++) { for (int i = 1; i <= 5; i++) {
emitter.onNext(i); emitter.onNext(i);
Thread.sleep((long) (Math.random() * 100));
} }
emitter.onComplete(); emitter.onComplete();
}).observeOn(Schedulers.io()); }).subscribeOn(Schedulers.io())
.observeOn(Schedulers.newThread());
integerObservable.subscribe(item -> System.out.println("Subscribe Next: " + item)); integerObservable.subscribe(item -> System.out.println("println: Subscribe Next: " + item));
integerObservable.subscribe(item -> log.info("[logInfo] Subscribe Next: {}", item)); integerObservable.subscribe(item -> log.info("[logInfo] Subscribe Next: {}", item));
integerObservable.blockingSubscribe();
Observable<Integer> take = Observable.fromArray(1, 2, 3, 4, 5) Observable<Integer> take = Observable.fromArray(1, 2, 3, 4, 5)
.observeOn(Schedulers.computation()).skip(2).take(1); .observeOn(Schedulers.computation()).skip(2).take(1);