Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/resonance-cascade/choo-location-electron
A choo subscription that fixes routing in electron
https://github.com/resonance-cascade/choo-location-electron
Last synced: 20 days ago
JSON representation
A choo subscription that fixes routing in electron
- Host: GitHub
- URL: https://github.com/resonance-cascade/choo-location-electron
- Owner: resonance-cascade
- License: isc
- Created: 2016-08-07T23:34:26.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-06T19:47:46.000Z (almost 7 years ago)
- Last Synced: 2024-02-18T21:09:56.743Z (4 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/choo-location-electron
- Size: 14.6 KB
- Stars: 12
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Lists
- awesome-choo - choo-location-electron - Fix `choo`'s router in electron. (Uncategorized / Uncategorized)
README
# choo-location-electron
A [choo](https://github.com/yoshuawuyts/choo) subscription that fixes routing in electron when loading a url from disk.
[![Build Status](https://travis-ci.org/hypermodules/choo-location-electron.svg?branch=master)](https://travis-ci.org/hypermodules/choo-location-electron)
**WARNING: Doesn't work with choo 4 right now**
See:
- https://github.com/hypermodules/hyperamp/issues/68
- https://github.com/yoshuawuyts/sheet-router/issues/72### Why?
When creating an electron browser window and loading the view from disk, `choo`'s router doesn't work out of the box due to the format of the resulting `file://` url. `choo-location-electron` provides a subscription that properly processes urls in `href` attributes of `a` tags so that they work with [sheet-router](https://github.com/yoshuawuyts/sheet-router) properly.
### Example
```js
const choo = require('choo')
const location = require('choo-location-electron')({ openExternal: true })
const app = choo()
app.model(location)// rest of your app
const tree = app.start({ href: false }) //REQUIRED SETTINGS
document.body.appendChild(tree)
```Note: Setting `href: false` is required in order to properly intercept click events on links.
### API
#### `var location = require('choo-location-electron')([opts])`
Return a choo subscription that properly handles internal and optionally external links in electron.
Default options:
```js
{
openExternal: false
}
```- `openExternal` (Optional Boolean): intercept URLs and open them in a web browser using `require('electron').shell.openExternal` (see [electron.atom.io/docs/api/shell/#shellopenexternalurl-options](http://electron.atom.io/docs/api/shell/#shellopenexternalurl-options)).
## See also
- [sethvincent/adventuretron/app/models/location.js](https://github.com/sethvincent/adventuretron/blob/c09a20cffb09650ce11f0195c150aaba13a9f45b/app/models/location.js#L25)