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

vue-crontab

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-crontab

Periodic processing management system (crontab) running on Vue.js

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

VueCrontab

Periodic processing management system (crontab) running on Vue.js

Introduction

VueCrontab is a plug-in for Vue.js that executes functions according to a specified schedule. The schedule consists of hours, minutes, seconds, days of the week, etc. VueCrontab executes the specified function when it matches the date and time. By using this you can easily implement periodic processing to run in the background.

Install

$ npm install vue-crontab

Examples

  • Simple vue component
  • Multi jobs
  • Use with the Vuex
  • Additional condition of the function.
  • Async of the functions

Usage

Counter updated every second.

import Vue from 'vue'
import VueCrontab from 'vue-crontab'

Vue.use(VueCrontab)

new Vue({
  el: '#app',
  render: h => h(App)
})
<template>
  <div id="app">
    <div>
      <div class="counter">{{ counter }}</div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      counter: 0
    }
  },
  created () {
    let result = this.$crontab.addJob({
      name: 'counter',
      interval: {
        seconds: '/1',
      },
      job: this.countUp
    })
  },
  methods: {
    countUp () {
      this.counter += 1
    }
  }
}
</script>

Reference

VueCrontab

option
nametypedescriptiondefault
intervalnumberThe interval to check the interval of the managed job.(milliseconds)1000
auto_startBooleanSetting whether to automatically move cron when one or more jobs are reached.true
examples

call setOption before Vue.use() method.

VueCrontab.setOption({
  interval: 100,
  auto_start: false
})

Vue.use(VueCrontab)
methods
nameargumentdescription
addJobArray or Object
enableJobstringEnable job with specified name.
disableJobstringDisable job with specified name.
deleteJobstringDelete job with specified name.
execJobstringManually execute the job with the specified name.
startCrontab-Stop the periodic processing of VueCrontab.
stopCrontab-Start the periodic processing of VueCrontab.
setOptionObjectchange option of VueCrontab.
getOption-get option of VueCrontab.

Job

option
nametypedescription
name (required)Stringjob name.
interval (required)Array or String or ObjectSpecify the periodical execution interval of the job.
job (required)Array or FunctionSpecify the function you want to execute when matching the interval.
syncnumberWhether to synchronize and execute when multiple jobs are registered. 1 = sync, 0 = not sync(default)
conditionArray or FunctionAdd a function when you want to additionally specify job execution conditions in addition to interval. The condition must return Boolean type.
interval
parameters
namerangedefault
milliseconds0 - 9*
seconds0 - 59*
minutes0 - 59*
hours0 - 23*
day1 - 31*
month1 - 12*
year0 -*
week0 - 6 (// Sunday is 0, Monday is 1, and so on.)*
Available symbols
namedescriptionexamples
*All ranges*
/Number divided by 0/2 = every 2 seconds. /5 = every 5 seconds.
-Within the specified numerical range0-10 = between 0 and 10 seconds.
,Used to connect conditions0,1,2 ... 0,10-20,/7 ...
interval examples

execute every 0.1 seconds

{milliseconds: '/1'}

If you want to process with milliseconds, change setOption as well.

VueCrontab.setOption({
  interval: 100
})

execute every minute.

{minutes: '/1'}

execute 0 minutes from 0 to 9 o'clock on the 1st of every month.

{seconds: '0', minutes:'0', hours: '0-9', day: '1'}

1,3,5,10-15 o'clock Monday

{week: '0', seconds: '0', minutes:'0', hours: '1,3,5,10-15'}
job arguments
nametypedescription
exec_dateDateMatch date and time.
last_runDateLast execution date and time.
counternumberNumber of executions.
last_resultanyReturn value of the previous function.
typeString'cron' = executed by periodic processing. 'manual = manually execution.
  methods: {
    countUp ({exec_date, last_run, counter, last_result, type}) {
      return "as the next last_result.";
    }
  }

License

MIT

Keywords

FAQs

Package last updated on 03 Mar 2019

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