Skip to content

Instantly share code, notes, and snippets.

@rsyring
Created November 20, 2017 04:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsyring/fbb54bb2f4b5bdf6cce892ee6a8fae32 to your computer and use it in GitHub Desktop.
Save rsyring/fbb54bb2f4b5bdf6cce892ee6a8fae32 to your computer and use it in GitHub Desktop.
Mithril Contacts
function Contacts(vn) {
let contacts = [
{name: 'Fred', email: 'fred@example.com'},
{name: 'Bob', email: 'bob@example.com'},
]
function addContact(contact) {
contacts.push(contact)
}
function delContact(email) {
// PROBLEM HERE
contacts = contacts.filter((el) => el.email !== email);
}
return {
view: function() {
return m("main", [
m(ContactForm, {addContact: addContact}),
m(ContactList, {contacts: contacts, delContact: delContact}),
])
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment