func (cb *ClientContextBuilder) SetApp(mockDispatcher, mockNotifier, mockWatcher bool) *ClientContextBuilder { app := &stores.App{ Conn: mock_connection.NewMockInterface(cb.mock), Fail: make(chan error, 1), } ctx := stores.NewContext(cb.Ctx(), app) cb.Base.SetCtx(ctx) app.Init(cb.Ctx()) if mockDispatcher { app.Dispatcher = mock_flux.NewMockDispatcherInterface(cb.mock) } if mockNotifier { app.Notifier = mock_flux.NewMockNotifierInterface(cb.mock) } if mockWatcher { app.Watcher = mock_flux.NewMockWatcherInterface(cb.mock) } return cb }
func Start() error { loc := dom.GetWindow().Location() addr := fmt.Sprintf("ws://%s:%s/_rpc", loc.Hostname, loc.Port) ws, err := websocket.Dial(addr) if err != nil { return kerr.Wrap("HNQFLPFAJD", err) } app := &stores.App{ Conn: connection.New(rpc.NewClient(ws)), Fail: make(chan error), } // We parse the info attribute from the body tag info, err := getInfo(getRawInfo()) if err != nil { return kerr.Wrap("MGLVIQIDDY", err) } var ctx context.Context ctx = context.Background() ctx = envctx.NewContext(ctx, &envctx.Env{Path: info.Path, Aliases: info.Aliases}) ctx = sysctx.NewContext(ctx) ctx = jsonctx.AutoContext(ctx) ctx = stores.NewContext(ctx, app) ctx = clientctx.NewContext(ctx) app.Init(ctx) // Don't do this. Implement the Editable interface instead. We can't do // this for system types so we use this method instead. editors.Register(ctx) if _, err := registerTypes(ctx, info.Path, info.Imports); err != nil { return kerr.Wrap("MMJDDOBAUK", err) } p := views.NewPage(ctx) vecty.RenderBody(p) // TODO: work out why I can't seem to call this without using eval js.Global.Get("window").Call("eval", "Split(['#tree', '#main'], {sizes:[25, 75]});") app.Dispatch(&actions.InitialState{ Info: info, }) go func() { err, open := <-app.Fail if !open { // Channel has been closed, so app should gracefully exit. fmt.Println("Server disconnected") } else { // Error received, so app should display error. fmt.Println(err.Error()) } }() return nil }