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

Change signature of Router.Create to deserialize to option #979

Closed
Jand42 opened this issue Jul 3, 2018 · 0 comments
Closed

Change signature of Router.Create to deserialize to option #979

Jand42 opened this issue Jul 3, 2018 · 0 comments
Assignees

Comments

@Jand42
Copy link
Member

Jand42 commented Jul 3, 2018

For creating routers for server/client shared use, this would be more useful than current Router.Create:

    let CreateRouter (ser: 'T -> list<string>) (des: list<string> -> option<'T>) =
        {
            Parse = fun path ->
                match des path.Segments with
                | Some ep ->
                    Seq.singleton ({ path with Segments = [] }, ep)
                | None ->
                    Seq.empty
            Write = fun value ->
                Some (Seq.singleton (Route.Segment(ser value)))
        } : Router<'T>

Current one is deserializing to 'T, not option<'T>, which is ok for fully client-side routing use when one of the EndPoint cases are representing a wrong URI, but not good for server-side use when even resource links would be hijacked by Sitelets routing if set up that way. Changing signature is a breaking change, but probably less confusing than having two different functions for the same basic goal, but one only working in a specific side case.

@Jand42 Jand42 self-assigned this Jul 5, 2018
Jand42 added a commit that referenced this issue Jul 5, 2018
@Jand42 Jand42 closed this as completed Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants