<commit_before>import 'rxjs/add/operator/map';

import { Injectable, Inject } from 'angular2/core';
import { AngularFire, FirebaseListObservable, FirebaseRef } from 'angularfire2';
import { AuthService } from 'src/core/auth';
import { ITask, Task } from './task';


@Injectable()
export class TaskService {
  taskItems$: FirebaseListObservable<ITask[]>;

  constructor(af: AngularFire, auth: AuthService, @Inject(FirebaseRef) private ref: Firebase) {
    const path = `/tasks/${auth.id}`;

    this.taskItems$ = af.list(path) as FirebaseListObservable<ITask[]>;

    // FirebaseListObservable currently lacks an `update()` method.
    // For now use FirebaseRef for updates.
    this.ref = ref.child(path);
  }

  createTask(title: string): Promise<any> {
    return this.taskItems$.add(new Task(title));
  }

  removeTask(task: ITask): Promise<any> {
    return this.taskItems$.remove(task.$key);
  }

  updateTask(task: ITask, changes: any): Promise<any> {
    return new Promise((resolve, reject) => {
      this.ref
        .child(task.$key)
        .update(changes, (error: Error) => {
          if (!error) {
            resolve();
          }
          else {
            console.error('ERROR @ updateTask :', error);
            reject();
          }
        });
    });
  }
}<commit_msg>refactor(TaskService): update methods to align with alpha.16<commit_after>import 'rxjs/add/operator/map';

import { Injectable } from 'angular2/core';
import { AngularFire, FirebaseListObservable } from 'angularfire2';
import { AuthService } from 'src/core/auth';
import { ITask, Task } from './task';


@Injectable()
export class TaskService {
  taskItems$: FirebaseListObservable<ITask[]>;

  constructor(af: AngularFire, auth: AuthService) {
    this.taskItems$ = af.list(`/tasks/${auth.id}`) as FirebaseListObservable<ITask[]>;
  }

  createTask(title: string): Promise<any> {
    return this.taskItems$.push(new Task(title));
  }

  removeTask(task: ITask): Promise<any> {
    return this.taskItems$.remove(task.$key);
  }

  updateTask(task: ITask, changes: any): Promise<any> {
    return this.taskItems$.update(task.$key, changes);
  }
}
{'fraction_non_alphanumeric': 0.14946286781877627, 'fraction_numerical': 0.0028024287716020553, 'mean_word_length': 3.606451612903226, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '944808', 'n_tokens_mistral': 686, 'n_tokens_neox': 671, 'n_words': 149}