This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyApp extends State<MyHomePage> { | |
int count = 0; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Column(children: <Widget>[ | |
Text('count $count',), | |
FlatButton(child: Text("Increment",), onPressed: () { setState(() { count++; });}), | |
FlatButton(child: Text("Decrement",), onPressed: () { setState(() { count--; });}), | |
])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
backgroundColor: Colors.teal, | |
body: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
Text( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
backgroundColor: Colors.teal, | |
body: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
Text( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subscription.add( | |
RxView.clicks(loginButton) | |
.map(click -> new LoginCommand(username.getText(), password.getText(), loginApiClient)) | |
.flatMap(Command::actions) | |
.subscribe(store::dispatch)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.groupon.grox.Store; | |
import com.groupon.grox.commands.rxjava1.Command; | |
import com.groupon.grox.sample.rx.R; | |
import rx.subscriptions.CompositeSubscription; | |
public class LoginActivity extends AppCompatActivity { | |
private LoginStateModel initialState = LoginStateModel.builder() | |
.setLoginState(LOGIN_NOT_STARTED) | |
.setLoggedInUser(null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.groupon.grox.Action; | |
public class LoginFailedAction implements Action<State> { | |
private Throwable throwable; | |
public ErrorAction(Throwable throwable){ | |
this.throwable = throwable; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.groupon.grox.Action; | |
public class LoginSuccessfulAction implements Action<LoginStateModel> { | |
private User user | |
public LoginSuccessfulAction(User user){ | |
this.user = user; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static rx.Observable.error; | |
import static rx.Observable.fromCallable; | |
import static rx.Observable.just; | |
import static rx.schedulers.Schedulers.io; | |
import com.groupon.grox.Action; | |
import com.groupon.grox.commands.rxjava1.Command; | |
import rx.Observable; | |
public class LoginCommand implements Command { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LoginStateModel initialState = LoginStateModel.builder() | |
.setLoginState(LOGIN_NOT_STARTED) | |
.setLoggedInUser(null) | |
.build(); | |
Store<LoginStateModel> store = new Store<>(initialState); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@AutoValue | |
public abstract class LoginStateModel { | |
public static Builder builder() { | |
return new AutoValue_LoginStateModel.Builder(); | |
} | |
public abstract Builder toBuilder(); | |
public abstract LoginState getLoginState(); |
NewerOlder