Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement client-server interaction via @server and @browser-session #620

Closed
wants to merge 6 commits into from

Conversation

ibdknox
Copy link
Contributor

@ibdknox ibdknox commented Nov 30, 2016

This adds a new kind of database that attempts to send its adds over the socket to either the client or the server depending on where it's running. It also adds the --clientAndServer flag, which allows you to run your program both on the client and server.

@ibdknox
Copy link
Contributor Author

ibdknox commented Nov 30, 2016

Example program I used to test:

## Main screen
```
search
  [#active-user name]

bind @browser
  [#div text: "Hello, {{name}}"]
```

## Login screen
Login screen is displayed when there is no active user:
```eve
search
  not([#active-user])

bind @browser
  [#div children:
    [#div children:
      [#label text: "Username:"]
      [#input #user-name type: "text"]]
    [#div children:
      [#label text: "Password:"]
      [#input #user-password type: "password"]]
    [#button #user-submit text: "Login"]]
```

Currently, submitting the form automatically succeeds:
```
search @browser @event
  [#click element: [#button #user-submit]]
  [#user-name value]

commit
  [#active-user name: value]
commit @server
  [#foo name: value]
```

```
search @server
  [#foo name]
commit @browser-session
  [#bar name]
```

```
search @browser-session
  [#bar name]
bind @browser
  [#div text: "hey {{name}} from the server"]
```

Copy link
Contributor

@joshuafcole joshuafcole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good. It raises a few questions about how this should interact with other aspects of the language, but so long as we mark this guy as being prototype only I don't see that as being blocking.

@@ -1,4 +1,4 @@
export enum Owner {client, server};
export enum Owner {client, server, both};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there any other options here? If not both is probably fine, but if so we might want to be more explicit.

@@ -118,6 +118,19 @@ export abstract class RuntimeClient {
actions.push(new ActionImplementations["+="]("event", e, a, v, "event", scopes));
}
this.evaluation.executeActions(actions);
} else if(data.type === "result" && (data.database === "server" || data.database === "browser-session")) {
// @TODO: should we allow databases other than server at some point?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we need to figure out how the extensibility story and policy story interact to give us this if we think it's important. This isn't blocking but it merits a research task.

// we need to add a browser-session bag and also make our local browser bag
// be a normal database that way we don't send UI that is already being handled
// by the client
if(config.runtimeOwner === Owner.both) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could potentially make client-server equipped code run on either/or as well if we always add this and just let it play telephone with itself. I don't know that doing so is particularly useful, but it may be good for testing at least.

@ibdknox
Copy link
Contributor Author

ibdknox commented Jan 6, 2017

I don't think this is the "right" solution moving forward, so closing this out for now.

@ibdknox ibdknox closed this Jan 6, 2017
@ibdknox ibdknox deleted the client-server branch March 9, 2017 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants