Meteor.setInterval을 사용하여 간단한 카운트 다운 타이머 (한 번에 1 초)를 만들려고합니다. 템플릿 (console.log에 의해 확인 됨)에서 모든 클릭 이벤트가 작동합니다. 그들은 메소드를 트리거하고 터미널의 console.log 이벤트를 통해 작업을 검증합니다.메서드에서 작동하도록 Meteor.setInterval을 가져올 수 없습니다.
다음을 시도합니다. - #start 클릭시 Meteor.setInterval 및 1000ms 간격으로 카운트 다운 타이머를 시작하십시오. - #pause에서 타이머 일시 중지 기존 intervalId를 0 간격으로 변경하여 클릭하십시오.- Meteor.clearInterval (id)을 사용하여 #cancel 클릭시 타이머를 취소하십시오.
나는 각각을 내 방법에 넣고 싶지만 작동하지 않는 것 같습니다. 나는 intervalId를 다시 얻지 못하고 다른 방법에 사용할 수 있습니다. 나는 또한 나의 간격 기능을두기 위하여 어디에서 확실하지 않다.
Meteor.setInterval 또는 Meteor.clearInterval을 포함하지 않고 코드를 포함 시켰습니다. 어디로 가야할지 모르겠습니다. 여기
커피 코드 :
if Meteor.isClient
Meteor.startup() ->
console.log "Client is Alive"
Session.setDefault("timerStartValue", 25)
Session.setDefault("timeRemaining", 25)
Template.timer.helpers
timeRemaining:() ->
Session.get("timeRemaining")
timerStartValue:() ->
Session.get("timerStartValue")
Template.timer.events
"click #start":() ->
console.log "Start button clicked."
Meteor.call("start", (error, result) ->
if error then console.log "Error is #{error}.")
"click #pause":() ->
console.log "Pause button clicked."
Meteor.call("pause", (error, result) ->
if error then console.log "Error is #{error}.")
"click #cancel":() ->
console.log "Cancel button clicked."
Meteor.call("cancel", (error, result) ->
if error then console.log "Error is #{error}.")
if Meteor.isServer
Meteor.startup() ->
console.log "Server is alive."
Meteor.methods
start:() ->
console.log "started on server."
pause:() ->
console.log "paused on server."
cancel:() ->
console.log "cancelled on server."