Add connection profiles (#63)

* Add connection setup

* Refactor

* Fix lifecycle
This commit is contained in:
Thomas Nordquist
2019-02-16 05:36:02 -08:00
committed by GitHub
parent f316d5699d
commit 93ea829987
19 changed files with 1225 additions and 418 deletions

View File

@@ -1,11 +1,16 @@
import { ActionTypes, Action, ConnectionState } from '../reducers/Connection'
import { MqttOptions } from '../../../backend/src/DataSource'
import { Dispatch } from 'redux'
import { rendererEvents, addMqttConnectionEvent, makeConnectionStateEvent, removeConnection } from '../../../events'
import { AppState } from '../reducers'
import * as q from '../../../backend/src/Model'
import { showTree } from './Tree'
import * as url from 'url'
import { Action, ActionTypes } from '../reducers/Connection'
import {
addMqttConnectionEvent,
makeConnectionStateEvent,
removeConnection,
rendererEvents,
} from '../../../events'
import { AppState } from '../reducers'
import { Dispatch } from 'redux'
import { MqttOptions } from '../../../backend/src/DataSource'
import { showTree } from './Tree'
import { TopicViewModel } from '../TopicViewModel'
export const connect = (options: MqttOptions, connectionId: string) => (dispatch: Dispatch<any>, getState: () => AppState) => {
@@ -15,6 +20,7 @@ export const connect = (options: MqttOptions, connectionId: string) => (dispatch
const host = url.parse(options.url).hostname
rendererEvents.subscribe(event, (dataSourceState) => {
console.log(dataSourceState)
if (dataSourceState.connected) {
const tree = new q.Tree<TopicViewModel>()
tree.updateWithConnection(rendererEvents, connectionId)