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

reduce toSession proliferation #79

Open
Hermanverschooten opened this issue Jun 8, 2019 · 2 comments
Open

reduce toSession proliferation #79

Hermanverschooten opened this issue Jun 8, 2019 · 2 comments

Comments

@Hermanverschooten
Copy link

In the code as supplied here, each page needs to have a toSession method exposed that essentially just returns the session field out of its model. Why not make this more generic?

getSession: { a | session: Session } -> Session
getSession =
    session

Then you can replace the calls in the case statement:

        ...
        Home home ->
            Home.toSession home

        Settings settings ->
            Settings.toSession settings

with

        ...
        Home home ->
           getSession home

        Settings settings ->
            getSession settings

And there is no longer a need to have a toSession in the pages, unless you want it.

@Sircular
Copy link

On that note, why have the session as part of the individual page models if it needs to be shared across all of them? Why is it not part of the top-level model?

@Hermanverschooten
Copy link
Author

The model here is a Type, not a Type alias, and you need the information in every page anyway, so you would have to pass it along.

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

2 participants