-
Notifications
You must be signed in to change notification settings - Fork 0
/
Meteor.elm.js
37 lines (31 loc) · 981 Bytes
/
Meteor.elm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Elm.Native.Meteor = {}
Elm.Native.Meteor.make = elm => {
elm.Native = elm.Native || {}
elm.Native.Meteor = elm.Native.Meteor || {}
if(elm.Native.Meteor.value) return elm.Native.Meteor.value
if(typeof window !== 'undefined') window.Elm = Elm
const Signal = Elm.Native.Signal.make(elm)
const Utils = Elm.Native.Utils.make(elm)
const List = Elm.Native.List.make(elm)
const Maybe = Elm.Maybe.make(elm)
const startup = Signal.input('Meteor.startup', false)
Meteor.startup(() => elm.notify(startup.id, true))
const getSetting = (keys, type) => {
let res = Meteor.settings
let arr = List.toArray(keys)
arr.forEach(key => { if(res) res = res[key] })
return ( res
? Maybe.Just(res)
: Maybe.Nothing
)
}
return elm.Native.Meteor.value = {
isServer: Meteor.isServer
, isClient: Meteor.isClient
, isCordova: Meteor.isCordova
, absoluteUrl: Meteor.absoluteUrl
, release: Meteor.release
, startup
, getSetting
}
}