Home / File/ app.js — vue Source File

app.js — vue Source File

Architecture documentation for app.js, a javascript file in the vue codebase.

Entity Profile

Relationship Graph

Source Code

// Full spec-compliant TodoMVC with localStorage persistence
// and hash-based routing in ~150 lines.

// localStorage persistence
var STORAGE_KEY = 'todos-vuejs-2.0'
var todoStorage = {
  fetch: function () {
    var todos = JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]')
    todos.forEach(function (todo, index) {
      todo.id = index
    })
    todoStorage.uid = todos.length
    return todos
  },
  save: function (todos) {
    localStorage.setItem(STORAGE_KEY, JSON.stringify(todos))
  }
}

// visibility filters
var filters = {
  all: function (todos) {
    return todos
  },
  active: function (todos) {
    return todos.filter(function (todo) {
      return !todo.completed
    })
  },
  completed: function (todos) {
    return todos.filter(function (todo) {
      return todo.completed
    })
  }
}

// app Vue instance
var app = new Vue({
  // app initial state
  data: {
    todos: todoStorage.fetch(),
    newTodo: '',
    editedTodo: null,
    visibility: 'all'
  },

  // watch todos change for localStorage persistence
  watch: {
    todos: {
      handler: function (todos) {
        todoStorage.save(todos)
      },
      deep: true
    }
  },

  // computed properties
  // https://v2.vuejs.org/v2/guide/computed.html
  computed: {
    filteredTodos: function () {
// ... (98 more lines)

Domain

Subdomains

Frequently Asked Questions

What does app.js do?
app.js is a source file in the vue codebase, written in javascript. It belongs to the VueCore domain, Observer subdomain.
What functions are defined in app.js?
app.js defines 6 function(s): filters.active, filters.all, filters.completed, onHashChange, todoStorage.fetch, todoStorage.save.
Where is app.js in the architecture?
app.js is located at examples/classic/todomvc/app.js (domain: VueCore, subdomain: Observer, directory: examples/classic/todomvc).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free