You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to implement an example with ReduxFX but I have a problem that is keeping me from using this project.
Here's an example:
@Override
public void start(Stage mainStage) throws Exception {
final AppState initialState = AppState.create();
ReduxFX.start(
initialState,
IncrementReducer::update,
HomeView::view,
mainStage);
}
public class HomeView {
public static VNode view(AppState state) {
Objects.requireNonNull(state, "The parameter 'state' must not be null");
return Stage().....;
}
}
public class IncrementReducer {
public static AppState update(AppState state, Object action) {
Objects.requireNonNull(state, "The parameter 'state' must not be null");
Objects.requireNonNull(action, "The parameter 'action' must not be null");
// This is part of Javaslang's pattern-matching API. It works similar to the regular switch-case
// in Java, except that it is much more flexible and returns a value.
// We check which of the cases is true and in that branch we specify the newState.
return Match(action).of(
// If the action is a IncCounterAction, we return a new AppState with an increased counter
Case(instanceOf(IncrementReducer.class),
incCounterAction -> state.withCounter(state.getCounter() + 1)
),
// This is the default branch of this switch-case. If an unknown Action was passed to the
// updater, we simply return the old state. This is a convention, that is not needed right
// now, but will help once you start to decompose your updater.
Case($(), state)
);
}
}
The Intellij hint gives me this alert Cannot resolve method 'start(com.renanliberato.app.state.AppState, <method reference>, <method reference>, javafx.stage.Stage)' and if I try to run it, it gives me this error:
Error:(28, 16) java: no suitable method found for start(com.renanliberato.app.state.AppState,IncrementR[...]pdate,HomeView::view,javafx.stage.Stage)
method com.netopyr.reduxfx.ReduxFX.<STATE>start(STATE,java.util.function.BiFunction<STATE,java.lang.Object,com.netopyr.reduxfx.updater.Update<STATE>>,java.util.function.Function<STATE,com.netopyr.reduxfx.vscenegraph.VNode>,javafx.stage.Stage) is not applicable
(cannot infer type-variable(s) STATE
(argument mismatch; bad return type in method reference
com.renanliberato.app.state.AppState cannot be converted to com.netopyr.reduxfx.updater.Update<STATE>))
method com.netopyr.reduxfx.ReduxFX.<STATE>start(STATE,java.util.function.BiFunction<STATE,java.lang.Object,com.netopyr.reduxfx.updater.Update<STATE>>,java.util.function.Function<STATE,com.netopyr.reduxfx.vscenegraph.VNode>,javafx.scene.Group) is not applicable
(cannot infer type-variable(s) STATE
(argument mismatch; bad return type in method reference
com.renanliberato.app.state.AppState cannot be converted to com.netopyr.reduxfx.updater.Update<STATE>))
method com.netopyr.reduxfx.ReduxFX.<STATE>start(STATE,java.util.function.BiFunction<STATE,java.lang.Object,com.netopyr.reduxfx.updater.Update<STATE>>,java.util.function.Function<STATE,com.netopyr.reduxfx.vscenegraph.VNode>,javafx.scene.layout.Pane) is not applicable
(cannot infer type-variable(s) STATE
(argument mismatch; bad return type in method reference
com.renanliberato.app.state.AppState cannot be converted to com.netopyr.reduxfx.updater.Update<STATE>))
In my pom.xml file I've imported this dependency, as included in the README.md:
I'd appreciate to know if this is some misunderstanding that I've made with Bifunction or anything else, because this may be an example of problems someone who didn't know this project may run when trying to implement it.
Will it help if I submit a gist with a more complete code example?
The text was updated successfully, but these errors were encountered:
thanks for trying out ReduxFX. I think you need to switch to the class SimpleReduxFX instead of ReduxFX (in the same package). Otherwise your code looks fine.
SimpleReduxFX gives you everything you need to implement your first examples and simple demos. But when you try to implement a real application, you will realize that one important piece is missing: SimpleReduxFX lacks the ability to communicate with anything that is not UI, e.g. servers, file-system etc. The class ReduxFX adds the missing functionality, but you have to return an instance of Update instead of the new state. Update contains the new state and an arbitrary list of commands, which are used to communicate with the outside world. You can find some more details here: https://github.com/netopyr/reduxfx/blob/master/doc/driver.md
Sorry that the documentation is not clear enough right now. Unfortunately the documentation is clearly one of the weak points at this point.
Hello,
I'm trying to implement an example with ReduxFX but I have a problem that is keeping me from using this project.
Here's an example:
The Intellij hint gives me this alert
Cannot resolve method 'start(com.renanliberato.app.state.AppState, <method reference>, <method reference>, javafx.stage.Stage)'
and if I try to run it, it gives me this error:In my
pom.xml
file I've imported this dependency, as included in the README.md:I'd appreciate to know if this is some misunderstanding that I've made with Bifunction or anything else, because this may be an example of problems someone who didn't know this project may run when trying to implement it.
Will it help if I submit a gist with a more complete code example?
The text was updated successfully, but these errors were encountered: