Home Manual Reference Source Repository
public class | source

App

Provides the main entry point for the Todos app and major control functionality (the C in MVC). This control functionality is exposed over an eventbus created by mainEventbus.js.

It should be noted that since this app is based on backbone-parse-es6 there are no additional lifecycle methods added to Backbone.View such as close which automatically removes all listeners defined by listenTo. Each view must explicitly have any listeners removed before creating a new view.

While in this simple app there is only one view of the TodoList a benefit of separating control functionality and the TodoList instance from a specific view is that it could be used across multiple views.

Constructor Summary

Public Constructor
public

Wires up the main eventbus, invokes the private s_INITIALIZE_ROUTE function which creates AppRouter and sets up a catch all handler then invokes Backbone.history.start with the root path and finally the constructor shows the proper view based on whether there is a current logged in user.

Member Summary

Public Members
public

Creates the initial displayed view based given if a user is currently logged into the app.

Method Summary

Public Methods
public

createItem(content: string)

Creates a new Item in the todos list.

public

Invokes showTodos if there is a current user.

public

Logs out the user and shows the login view.

public

selectFilter(filter: string)

Sets the app state with the new filter type and updates Backbone.History.

public

showTodos(username: string): *

Creates and shows a new ManageTodosView then sets a new Parse.Query for todoList for the current user and fetches the collection.

Public Constructors

public constructor source

Wires up the main eventbus, invokes the private s_INITIALIZE_ROUTE function which creates AppRouter and sets up a catch all handler then invokes Backbone.history.start with the root path and finally the constructor shows the proper view based on whether there is a current logged in user.

Public Members

public currentView: View source

Creates the initial displayed view based given if a user is currently logged into the app.

Public Methods

public createItem(content: string) source

Creates a new Item in the todos list. Note the addition of user which becomes a Parse pointer and an Parse.ACL (access control list) which limits the item to be only accessible to the current user.

Params:

NameTypeAttributeDescription
content string

The text for the item.

public logInUser() source

Invokes showTodos if there is a current user.

public logOutUser() source

Logs out the user and shows the login view.

public selectFilter(filter: string) source

Sets the app state with the new filter type and updates Backbone.History.

Params:

NameTypeAttributeDescription
filter string

Filter type to select.

public showTodos(username: string): * source

Creates and shows a new ManageTodosView then sets a new Parse.Query for todoList for the current user and fetches the collection.

Params:

NameTypeAttributeDescription
username string

Name of current user.

Return:

*