本文整理了Java中com.spotify.mobius.Next.effects()
方法的一些代码示例,展示了Next.effects()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Next.effects()
方法的具体详情如下:
包路径:com.spotify.mobius.Next
类名称:Next
方法名:effects
[英]Get the effects of this Next.
Will return an empty set if there are no effects.
[中]下一步,看看这个的效果。
如果没有效果,将返回一个空集。
代码示例来源:origin: spotify/mobius
/** Check if this Next contains effects. */
public final boolean hasEffects() {
return !effects().isEmpty();
}
代码示例来源:origin: com.spotify.mobius/mobius-core
/** Check if this Next contains effects. */
public final boolean hasEffects() {
return !effects().isEmpty();
}
代码示例来源:origin: spotify/mobius
@Override
protected boolean matchesSafely(Next<M, F> item, Description mismatchDescription) {
if (!item.hasEffects()) {
mismatchDescription.appendText("no effects");
return false;
} else if (!matcher.matches(item.effects())) {
mismatchDescription.appendText("bad effects: ");
matcher.describeMismatch(item.effects(), mismatchDescription);
return false;
} else {
mismatchDescription.appendText("has effects: ");
matcher.describeMismatch(item.effects(), mismatchDescription);
return true;
}
}
代码示例来源:origin: spotify/mobius
@Override
public void afterUpdate(M model, E event, Next<M, F> result) {
if (result.hasModel()) {
LOGGER.debug(LOGGING_PREFIX + "Model updated: {}", loggingTag, result.modelUnsafe());
}
for (F effect : result.effects()) {
LOGGER.debug(LOGGING_PREFIX + "Effect dispatched: {}", loggingTag, effect);
}
}
代码示例来源:origin: spotify/mobius
@Override
public void afterUpdate(M model, E event, Next<M, F> result) {
if (result.hasModel()) {
Log.d(tag, "Model updated: " + result.modelUnsafe());
}
for (F effect : result.effects()) {
Log.d(tag, "Effect dispatched: " + effect);
}
}
代码示例来源:origin: spotify/mobius
synchronized void update(E event) {
if (!initialised) {
eventsReceivedBeforeInit.add(event);
return;
}
Next<M, F> next = store.update(event);
next.ifHasModel(
new Consumer<M>() {
@Override
public void accept(M model) {
dispatchModel(model);
}
});
dispatchEffects(next.effects());
}
代码示例来源:origin: com.spotify.mobius/mobius-core
synchronized void update(E event) {
if (!initialised) {
eventsReceivedBeforeInit.add(event);
return;
}
Next<M, F> next = store.update(event);
next.ifHasModel(
new Consumer<M>() {
@Override
public void accept(M model) {
dispatchModel(model);
}
});
dispatchEffects(next.effects());
}
代码示例来源:origin: spotify/mobius
@Test
public void shouldNotBeSensitiveToExternalMutation() throws Exception {
Set<String> inputs = new HashSet<>();
inputs.add("in");
Next<String, String> next = Next.next("#", inputs);
inputs.add("don't want to see this one");
assertThat(next.effects(), equalTo((Set) Sets.newHashSet("in")));
}
代码示例来源:origin: spotify/mobius
@Test
public void canMergeInnerEffects() throws Exception {
Next<String, String> outerNext = Next.next("m", effects("f1", "f2"));
Next<?, String> innerNext = dispatch(effects("f2", "f3"));
Next<String, String> merged =
Next.next(
outerNext.modelOrElse("fail"), unionSets(innerNext.effects(), outerNext.effects()));
assertEquals(Next.next("m", effects("f1", "f2", "f3")), merged);
}
代码示例来源:origin: spotify/mobius
@Nonnull
public final Next<M, F> update(M model, E event) {
MI innerModel = checkNotNull(modelExtractor().apply(model));
EI innerEvent = checkNotNull(eventExtractor().apply(event));
Next<MI, FI> innerNext = checkNotNull(innerUpdate().update(innerModel, innerEvent));
M newModel = model;
boolean modelUpdated = innerNext.hasModel();
if (modelUpdated) {
newModel = checkNotNull(modelUpdater().apply(model, innerNext.modelUnsafe()));
}
return checkNotNull(
innerEffectHandler().handleInnerEffects(newModel, modelUpdated, innerNext.effects()));
}
代码示例来源:origin: spotify/mobius
@Test
public void canMergeInnerEffectsAndModel() throws Exception {
Set<String> effects = setOf("f1", "f2");
Next<Integer, String> innerNext = Next.next(1, effects("f2", "f3"));
Next<String, String> merged =
Next.next("m" + innerNext.modelOrElse(0), unionSets(effects, innerNext.effects()));
assertEquals(Next.next("m1", effects("f1", "f2", "f3")), merged);
}
内容来源于网络,如有侵权,请联系作者删除!