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

web-atoms-mvvm-todo

v1.0.3

Published

Web Atoms MVVM Todo Sample

Downloads

3

Readme

Installation

npm install web-atoms-generator typescript -g

Web Atoms MVVM Sample

Sample Todo Application using Web Atoms MVVM contains following features.

  • REST Service and Mock
  • Small and Minimal Dependency Injection
  • View Model and Reusable Components
  • Unit Tests

Components

Components are organized in app/views folder. Component generator uses waconfig.json to convert HTML components into views.js, it also contains views.js.d.ts so you can statically reference them in your typescript files.

  1. TaskStatusCombo dropdown is reusable dropdown that loads values from ConfigService
  2. TaskListView is a main view that hosts list of tasks and button to add/remove tasks.
  3. NewTaskWindow is window components that will allow you to validate/edit and save task.

Services

REST Services are kept in app/services folder. They are decorated with HTTP methods and parameter bindings.

  1. TaskService provides CRUD operations on tasks.
  2. ConfigSerice provides configuration lists such as status list etc.

Models

In this folder, Task and ConfigItem models are stored, Task is a class where else ConfigItem is just a type.

View Models

Components have corresponding View Model in app/view-models folder. Not every component needs ViewModel.

TaskListViewModel

  1. TaskListViewModel provides list of tasks, which are loaded asynchronously from TaskService in init method.
  2. It provides add/remove method for task.
  3. In add method it opens new task window and awaits for result asynchronously.

NewTaskWindowViewModel

  1. NewTaskWindowViewModel provides task model and validation for the model.
  2. Validations are added as inline lambda expressions. Validation expression is evaluated automatically when any referenced property is modified.
  3. When you call this.close(task) method, parameter task is resolved in promise that was created when the task list opened a window.

Unit Tests

We have created two unit tests.

Test for Task List View Model

  1. We will call expectWindow on MockWindowService.instance to register what window should open when we call a method. We will also provide result that we will expect to resolve in promise.
  2. We will verify that second task in the list is the new task we were expecting from the window.

NewTaskWindow Test

  1. We will call expectAlert to notify test manager that we will expect an alert when we will try to save empty task.
  2. We will call expectAlert again after setting label.
  3. In end of test we will call MockWindowService.instance.assert(), that will throw an error if any of expected alert/window was never called from the target methods.