Code Monkey home page Code Monkey logo

nemo-keepalive's Introduction

nemo-keepalive's People

Contributors

spiiroin avatar thp avatar martinjones avatar pvuorela avatar faenil avatar lbt avatar vdvsx avatar

Stargazers

Robert Scheinpflug avatar Riccardo Ferrazzo avatar  avatar Jukkis Virtanen avatar

Watchers

Dmitry Rozhkov avatar Marko Mattila avatar John Brooks avatar Denis Zalevskiy avatar  avatar Juho Hämäläinen avatar Jonni Rainisto avatar Islam Amer avatar Richard Braakman avatar Giulio Camuffo avatar Bernd Wachter avatar  avatar Kalle Jokiniemi avatar Tom Swindell avatar James Cloos avatar Jakub Pavelek avatar Nicola De Filippo avatar Riccardo Ferrazzo avatar Juha Kallioinen avatar Hannu Mallat avatar Petri M. Gerdt avatar Antti Seppälä avatar Joona Petrell avatar Philippe De Swert avatar Jarkko Nikula avatar  avatar  avatar  avatar mvogt avatar Mikko Harju avatar Raine Mäkeläinen avatar Matti Kosola avatar Kimmo Lindholm avatar Aaron McCarthy avatar  avatar Slava Monich avatar Gunnar Sletta avatar

nemo-keepalive's Issues

Make BackgroundJob behave more like Timer: add triggeredOnStart and repeat properties, and suppress additional triggered signals after enabled has been set to false

Currently BackgroundJob always triggers immediately when enabled is set to true. There's also no way to tell BackgroundJob to behave like a single-shot timer. Though it's certainly possible to work around this, by keeping track of whether the BackgroundJob has already triggered once and disabling it when you've done the work that needs to be done, it would be helpful if you could add the two boolean properties triggeredOnStart and repeat that work the QtQuick Timer type's properties of the same name.

Additionally, if enabled is set to false after finished() has already been called, BackgroundJob will still trigger once more. For a demonstration of this behaviour, take a look at this code, adapted from examples/qml/backgroundjob.qml (the only change is the removal of line 41, which normally hides the text when the BackgroundJob is disabled):

import QtQuick 2.0
import Sailfish.Silica 1.0
import org.nemomobile.keepalive 1.0

ApplicationWindow {
  initialPage: Page {
    Timer {
      id: timer
      interval: 1000
      repeat: true
      property int run_periods
      onTriggered: {
        if (--run_periods == 0) {
          backgroundJob.finished()
          stop()
        }
      }
    }

    BackgroundJob {
      id: backgroundJob
      frequency: BackgroundJob.ThirtySeconds
      onTriggered: {
        timer.run_periods = 5
        timer.running = true
      }
    }

    Column {
        width: parent.width
        spacing: Theme.paddingLarge
        anchors.centerIn: parent
        Label {
            anchors.horizontalCenter: parent.horizontalCenter
            text: backgroundJob.running ? "running job " + timer.run_periods : "job waiting"
        }
        Button {
            text: backgroundJob.enabled ? "Disable" : "Enable"
            anchors.horizontalCenter: parent.horizontalCenter
            onClicked: {
                backgroundJob.enabled = !backgroundJob.enabled
            }
        }
    }
  }
}

If you press the "Disable" Button while the Label displays "job waiting", the Timer will nevertheless be started again a few seconds later by the BackgroundJob, after which backgroundJob.running will be perpetually set to true, i.e. "running job 0" will be displayed.

This seems like very strange behaviour to me. I would definitely not expect the BackgroundJob to trigger again in spite of its enabled property being set to false.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.