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

View adapters #95

Closed
NickSeagull opened this issue Jul 27, 2024 · 0 comments
Closed

View adapters #95

NickSeagull opened this issue Jul 27, 2024 · 0 comments

Comments

@NickSeagull
Copy link
Contributor

NickSeagull commented Jul 27, 2024

At the time of writing this issue, the view function from the user has the signature:

view :: Model -> Text

Platform is executing it as-is, and rendering it. The next step would be to use some other type like Html to allow structured rendering, but views could be used also for GET endpoints for backends:

Essentially, a view is a way of seeing the state of the application in a specific way.

Given that in NeoHaskell the state is (conceptually) a single record, it makes sense to allow defining views that are executed on demand.

Right now the demand is handled by the platform automatically (when a new frame has to be rendered, it executes the function and renders it using a render :: Text -> IO () function).

This means that we have two functions that work together for the sake of the proper "viewing" of the model:

view :: Model -> Text

render :: Text -> IO ()

We should allow to provide, for example, an HTTP server view adapter, so the user can write a view function that outputs JSON, and the HTTP server returns it back.

This should be extendable to anything that can query data: GRPC, IPC, sockets, whatever

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

No branches or pull requests

1 participant