Socket
Socket
Sign inDemoInstall

ember-cli-clock

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-cli-clock

A very simple observable clock service for EmberJS.


Version published
Weekly downloads
141
increased by24.78%
Maintainers
1
Weekly downloads
 
Created
Source

Clock

A very simple observable clock service for EmberJS.

I display time in many of my projects and need to keep the displayed time up-to-date so I generalized the solution to this Ember CLI Add-on.

Live Demo

Build Status

Installation

ember install ember-cli-clock

Usage

Inject the clock service: clock: Ember.inject.service(). Now you can observe changes like so for use with MomentJS:

App.TweetComponent = Ember.Component.extend({
  posted: Ember.computed('clock.minute', function() {
    return moment(this.get('timestamp')).fromNow();
  })
});

{{posted}} outputs "2 minutes ago" and updates every minute

Or a clock that uses the local system time and updates every second.

App.ClockComponent = Ember.Component.extend({
  time: Ember.computed('clock.second', function() {
    return moment().format('h:m:s');
  })
});

API

You can observe or display the following properties:

  • second
  • minute
  • five
  • quarter
  • hour

Each one is an incrementing integer.

During testing you may also set a custom interval time to speed up your tests. For example use this.clock.set('intervalTime', 100); to run the clock 10 times faster.

You may also reset the clock to 0 using this.clock.reset();

Authors

Copyright (c) 2014 Jerel Unruh and contributors

Licensed under the MIT license

Keywords

FAQs

Package last updated on 11 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc