npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

apptivity

v1.1.4

Published

Stateful Activities as Improvement in Software Development

Downloads

11

Readme

apptivity

npm version

An activity workflow player that sequentially runs action, condition, fork, merge and prompt input actions.

This library has the following features.

  1. Convenient and rich definition API to define and configure Workflow activities and actions. It helps developers to focus on overall activity logic before detailing them with their implementations.

  2. Flexible definition API allows splitting of Worfklow activity definition with their implementation, keeping files and directories of Workflow modules organized.

  3. Workflow activities and actions are more predictable as they each publish an immutable state object containing unique state name, action name, request data, and response data per completed run of Activity action.

  4. Activity action supports asynchronous runs by supplying a callback function that returns Promise Object when defining Action implementations using handler(callback:Function) or guard(callback:Function) methods.

  5. Workflows' internal Finite State Machine can be exported into any custom JSON schema using workflow.trasform(workflowName:String).

Installation

This little library is packaged by npm. Source can be found in github repository

npm install apptivity --save

Usage

Create a Workflow activity and chain-configure actions with definition API.

var workflow = require('./index.js');

workflow.create("createUser").
			// create action
			action("fetchFromBackend").
            	describe("fetch something from the backend",
                		"or find something to populate the initial input data",
                        "Remember: [describe], [guard] and [handler] is optional").
				guard(function (input) {
                	return Promise.resolve(input);
                }).
                handler(function (input) {
                	return Ajax.requestAndReturnPromise(input);
                }).
			// your last action
			action("renderAndExit").
            	describe("Nothing special if no [handler]").
                handler(function (data) {
                	return { name: "whatever! this will be your last data" };
                });

Run the newly created Workflow activity and monitor state changes.

workflow("createUser").
	// register event listener
	on("state-change",
        function (session, data) {
        	console.log("state: ", session.state === data);
            console.log("yes! do something about this immutable [data]");
        }).
	// run the workflow
    run({ name: "first input" });

Listen to other running Workflow activity sessions' state-change event.

var stopListening = workflow.subscribe("createUser", "state-change",
								function (session, data) {
                                	console.log("what should I do with this?");
                                });
// I change my mind, I don't have to listen to "createUser" workflow's  "state-change" events
stopListening();

Note: You can subscribe to a workflow event anytime even if the workflow does not exist.

Export the workflow into Finite State Machine configuration to create an instance of javascript-state-machine.

var StateMachine = require("javascript-state-machine");

var createUserStateMachine = StateMachine.create(
								workflow.transform('createUser'));

Documentation

API Documentation is now hosted in a separate page. You can explore it from Apptivity Project page.

License

MIT