elmish / browser

Routing and Navigation for browser apps
https://elmish.github.io/browser
Other
35 stars 20 forks source link

add Parser.pathUrl #28

Closed forki closed 4 years ago

forki commented 4 years ago

The current parser works on Browser.Types.Location. It would be great for React Native to have one that works on strings. Can we use the following?

    let urlParser (url:string) =
        let pos = url.IndexOf "?"
        if pos >= 0 then
            let path = url.Substring(0,pos)
            let search = url.Substring(pos)
            parse configParser path (parseParams search)
        else
            parse configParser url Map.empty
et1975 commented 4 years ago

This repo is for browsers specifically (where Location is guaranteed to be present) and I guess I'm not clear on how you'd use it in RN environment. Can you describe? We could split parser out into its own package I suppose and maybe put this code into elmish.react...

forki commented 4 years ago

https://facebook.github.io/react-native/docs/linking#basic-usage

It allows you to do deep linking into your app. I'd like to parse those links and feed into elmish

Eugene Tolmachev notifications@github.com schrieb am Mi., 27. Nov. 2019, 16:03:

This repo is for browsers specifically (where Location is guaranteed to be present) and I guess I'm not clear on how you'd use it in RN environment. Can you describe? We could split parser out into its own package I suppose and maybe put this code into elmish.react...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/elmish/browser/issues/28?email_source=notifications&email_token=AAAOANEGLADIBTINKTBZNGDQV2D3HA5CNFSM4JSDJ2J2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFJY5QA#issuecomment-559124160, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAOANG56NZKUKJ7GCLBTGTQV2D3HANCNFSM4JSDJ2JQ .

et1975 commented 4 years ago

Makes sense, yeah I think I'll extract the url parser into itsown package.

forki commented 4 years ago

Cool. Thanks

Eugene Tolmachev notifications@github.com schrieb am Mi., 27. Nov. 2019, 16:57:

Makes sense, yeah I think I'll extract the url parser into itsown package.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/elmish/browser/issues/28?email_source=notifications&email_token=AAAOANFKSI6HAPZFCISJLBTQV2KGJA5CNFSM4JSDJ2J2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFJ6P7A#issuecomment-559147004, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAOANAGRDEWTPVOIX4ICM3QV2KGJANCNFSM4JSDJ2JQ .

et1975 commented 4 years ago

Released in the new package https://github.com/elmish/urlParser as Fable.Elmish.UrlParser@1.0.0-alpha-1 and it's now available for CLR as well (Elmish.UrlParser@1.0.0-alpha-1). elmish-urlParser will be a dependency for elmish-browser from v4 onward.

forki commented 4 years ago

Awesome. Thanks

Eugene Tolmachev notifications@github.com schrieb am Fr., 29. Nov. 2019, 21:38:

Closed #28 https://github.com/elmish/browser/issues/28.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/elmish/browser/issues/28?email_source=notifications&email_token=AAAOANHRNQANMJRMXK3KYYLQWF4TVA5CNFSM4JSDJ2J2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOVFULKKY#event-2842211627, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAOANBH3YUIMFRQZRBS62TQWF4TVANCNFSM4JSDJ2JQ .