토스프론트 플러그인 타이머 (startTimer)템플릿의 stop기능이 있나요?
-
-
안녕하세요. 토스플레이스 개발자센터입니다.
startTimer를 호출할 때 반환되는 함수를 실행하면 타이머를 중지할 수 있습니다. 중지한 뒤 startTimer를 다시 호출하면 설정한 시간부터 새로 시작합니다.
문의하신 흐름은 다음과 같이 구현해 주세요.
- startTimer를 호출하고, 반환된 중지 함수를 보관합니다.
- 사용자의 터치·입력 이벤트가 발생하면 보관한 함수를 실행해 기존 타이머를 중지합니다.
- startTimer를 다시 호출하고, 새로 반환된 중지 함수로 교체합니다.
터치나 입력만으로 타이머가 자동 초기화되지는 않으므로, 해당 이벤트에 중지·재시작 처리를 연결해 주세요. 입력 템플릿에서는 input.onChange를 활용할 수 있습니다.
기존 타이머가 실행 중인 상태에서 startTimer를 다시 호출하면 오류가 발생하므로 반드시 먼저 중지해 주세요. 화면을 벗어날 때도 타이머를 중지해 주세요. 중지 함수 실행만으로는 onTimeout이 호출되지 않습니다.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
등록 로그인