-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtmdb-client.js
43 lines (36 loc) · 925 Bytes
/
tmdb-client.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
37
38
39
40
41
42
43
let reactive = new ReactiveDict('ready', false)
class Client {
constructor(){
console.warn('YOU SHOULD NOT BE INSTANTIATING THIS CLASS!')
return null
}
static get ready(){
return reactive.get('ready')
}
static get config(){
return Client._config
}
static set config(value){
Client._config = value
}
static imagePath(filename, sizeIndex=2){
if( !Client.ready ){
console.warn('TMDB config is not loaded.')
return filename
}
let img = Client.config.data.images,
path = img.secure_base_url
path += img.profile_sizes[sizeIndex]
path += filename
return path
}
}
TMDB.Client = Client
Meteor.startup(()=>{
let TMDBConfigurationSettings = new Mongo.Collection('tmdb-config')
Meteor.subscribe('tmdb-config')
Tracker.autorun(()=>{
Client.config = TMDBConfigurationSettings.findOne()
reactive.set('ready', (Client.config))
})
})