summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2016-12-03 09:43:12 -0700
committermo khan <mo@mokhan.ca>2016-12-03 09:43:12 -0700
commit65bb3c8e064d9c3a0257fe9dcd5c3e7068eb9b09 (patch)
tree0c0bdc5f0a0ad35a5e99ea2b012a28b3c488aab5 /app
parent0c280cf73f77b9b53d0b025ac6ee566d65528eaf (diff)
extract application-component.
Diffstat (limited to 'app')
-rw-r--r--app/components/application-component.js13
-rw-r--r--app/screens/login-screen.js19
2 files changed, 17 insertions, 15 deletions
diff --git a/app/components/application-component.js b/app/components/application-component.js
new file mode 100644
index 0000000..f9fc1fd
--- /dev/null
+++ b/app/components/application-component.js
@@ -0,0 +1,13 @@
+import React, { Component } from 'react';
+
+export default class ApplicationComponent extends Component {
+ componentDidMount() {
+ console.log("MOUNTED");
+ this.props.eventAggregator.subscribe('LOGGED_IN', this);
+ }
+
+ componentWillUnmount() {
+ console.log("UNMOUNTING");
+ this.props.eventAggregator.unsubscribe(this);
+ }
+}
diff --git a/app/screens/login-screen.js b/app/screens/login-screen.js
index b85dcb0..c8db3ab 100644
--- a/app/screens/login-screen.js
+++ b/app/screens/login-screen.js
@@ -1,28 +1,17 @@
-import React, { Component } from 'react';
+import React from 'react';
import { View, Button, StyleSheet } from 'react-native';
import Account from '../domain/account'
import Api from '../infrastructure/api'
import DashboardScreen from './dashboard-screen'
+import ApplicationComponent from '../components/application-component'
var t = require('tcomb-form-native');
var Form = t.form.Form;
-export default class LoginScreen extends Component {
+export default class LoginScreen extends ApplicationComponent {
constructor(props) {
super(props)
- this.state = {
- account: { username: 'mokha', password: '' }
- };
- }
-
- componentDidMount() {
- console.log("MOUNTED");
- this.props.eventAggregator.subscribe('LOGGED_IN', this);
- }
-
- componentWillUnmount() {
- console.log("UNMOUNTING");
- this.props.eventAggregator.unsubscribe(this);
+ this.state = { account: { username: 'mokha', password: '' } };
}
render() {