Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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

[![Build Status](https://travis-ci.org/jerel/ember-cli-clock.svg?branch=master)](https://travis-ci.org/jerel/ember-cli-clock)

  • 2.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
120
decreased by-9.09%
Maintainers
1
Weekly downloads
 
Created
Source

ember-cli-clock

Build Status

A simple clock service for Ember.js

Live Demo

View a live demo here: http://clock.jerel.co/

Installation

ember install ember-cli-clock

Usage

  1. Generate a clock service

    ember generate clock my-shiny-new-clock

  2. Inject the my-shiny-new-clock service into your component, controller, route, ...

    clock: Ember.inject.service('my-shiny-new-clock')

  3. Use the time (Date.now()) and date (Date instance) properties of the clock service

Examples

// app/components/iso-date.js

export default Ember.Component.extend({
  clock: Ember.inject.service('my-shiny-new-clock'),

  iso: Ember.computed('clock.date', function() {
    return this.get('clock.date').toISOString();
  })
});

Using {{iso}} in the template will output something like 2011-10-05T14:48:00.000Z and update it every second.

// app/components/device-status.js

export default Ember.Component.extend({
  clock: Ember.inject.service('my-shiny-new-clock'),

  isOnline: Ember.computed('lastContact', 'clock.time', function() {
    return this.get('clock.time') - this.get('lastContact') < 60 * 1000;
  })
});

The isOnline property is updated every second and will tell if the last contact of the device was less than 60 seconds ago.

API

Properties

  • interval (default: 1000ms) - the update interval of time and date
  • time (read-only) - will be set to Date.now() every interval milliseconds
  • date (read-only) - computed property: new Date(this.get('time'))

Methods

  • start() - starts the clock after it has been stopped
  • stop() - stops the clock from updating time and date until restarted

Authors

Copyright (c) 2014 Jerel Unruh and contributors

Licensed under the MIT license

Keywords

FAQs

Package last updated on 16 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