Skip to content

Commit

Permalink
Removed a lot of ancient todo's
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Dec 22, 2016
1 parent f7f4169 commit 6eb5b00
Show file tree
Hide file tree
Showing 18 changed files with 20 additions and 31 deletions.
3 changes: 0 additions & 3 deletions src/api/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ const actionFieldDecorator = createClassPropertyDecorator(
true
);


// TODO action.bind

export function action<A1, R, T extends (a1: A1) => R>(fn: T): T;
export function action<A1, A2, R, T extends (a1: A1, a2: A2) => R>(fn: T): T;
export function action<A1, A2, A3, R, T extends (a1: A1, a2: A2, a3: A3) => R>(fn: T): T;
Expand Down
1 change: 0 additions & 1 deletion src/api/expr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {isComputingDerivation} from "../core/derivation";
*
*/
export function expr<T>(expr: () => T, scope?): T {
// TODO: deprecate in 3.0? seems to be hardly used..
if (!isComputingDerivation())
console.warn("[mobx.expr] 'expr' should only be used inside other reactive functions.");
// optimization: would be more efficient if the expr itself wouldn't be evaluated first on the next change, but just a 'changed' signal would be fired
Expand Down
2 changes: 1 addition & 1 deletion src/api/extendobservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function extendObservableHelper(target: Object, defaultEnhancer: IEnhancer<any>,

const adm = asObservableObject(target);
const definedProps = {};
// TODO: could be optimised if properties.length === 1
// Note could be optimised if properties.length === 1
for (let i = properties.length - 1; i >= 0; i--) {
const propSet = properties[i];
for (let key in propSet) if (definedProps[key] !== true && hasOwnProperty(propSet, key)) {
Expand Down
1 change: 0 additions & 1 deletion src/api/observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export interface IObservableFactory {
<T>(wrapped: IModifierDescriptor<T>): T;
(target: Object, key: string, baseDescriptor?: PropertyDescriptor): any;
<T>(value: T[]): IObservableArray<T>;
// TODO: add map overload
(value: string): IObservableValue<string>;
(value: boolean): IObservableValue<boolean>;
(value: number): IObservableValue<number>;
Expand Down
5 changes: 1 addition & 4 deletions src/core/computedvalue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class ComputedValue<T> implements IObservable, IComputedValue<T>, IDeriva
protected value: T | undefined = undefined;
name: string;
isComputing: boolean = false; // to check for cycles
isRunningSetter: boolean = false; // TODO optimize, see: https://reaktor.com/blog/javascript-performance-fundamentals-make-bluebird-fast/
isRunningSetter: boolean = false;
setter: (value: T) => void;

/**
Expand All @@ -60,7 +60,6 @@ export class ComputedValue<T> implements IObservable, IComputedValue<T>, IDeriva
* This is useful for working with vectors, mouse coordinates etc.
*/
constructor(public derivation: () => T, public scope: Object | undefined, private compareStructural: boolean, name: string, setter?: (v: T) => void) {
// TODO: instead of comparestructural, pass a modifier
this.name = name || "ComputedValue@" + getNextId();
if (setter)
this.setter = createAction(name + "-setter", setter) as any;
Expand Down Expand Up @@ -185,8 +184,6 @@ export class ComputedValue<T> implements IObservable, IComputedValue<T>, IDeriva
const isTracking = Boolean(globalState.trackingDerivation);
const observing = unique(this.isComputing ? this.newObserving! : this.observing).map((dep: any) => dep.name);
const observers = unique(getObservers(this).map(dep => dep.name));
// TODO: use issue
// TOOD; expand wiht more states
return (`
WhyRun? computation '${this.name}':
* Running because: ${isTracking ? "[active] the value of this computation is needed by a reaction" : this.isComputing ? "[get] The value of this computed was requested outside a reaction" : "[idle] not running at the moment"}
Expand Down
3 changes: 1 addition & 2 deletions src/core/derivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export enum IDerivationState {
/**
* A derivation is everything that can be derived from the state (all the atoms) in a pure manner.
* See https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
* TODO: the one above is outdated, new one?
*/
export interface IDerivation extends IDepTreeNode {
observing: IObservable[];
Expand All @@ -44,7 +43,7 @@ export interface IDerivation extends IDepTreeNode {
unboundDepsCount: number;
__mapid: string;
onBecomeStale();
recoverFromError(); // TODO: revisit implementation of error handling
recoverFromError();
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/core/observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ function invariantLOS(observable: IObservable, msg) {
* It's hard or maybe inpossible (with reasonable perf) to get it right with current approach
* Hopefully self reruning autoruns aren't a feature people shuold depend on
* Also most basic use cases shuold be ok
* TODO: create description of autorun behaviour or change this behaviour?
*/

// Called by Atom when it's value changes
Expand Down
1 change: 0 additions & 1 deletion src/core/spy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export function spyReportStart(event) {

const END_EVENT = { spyReportEnd: true };

// TODO: change signature to spyReportEnd(time?: number)
export function spyReportEnd(change?) {
if (change)
spyReport(objectAssign({}, change, END_EVENT));
Expand Down
8 changes: 7 additions & 1 deletion src/types/observablemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,13 @@ export class ObservableMap<V> implements IInterceptable<IMapWillChange<V>>, ILis
}, undefined, false);
}

// TODO: replace
replace(values: ObservableMap<V> | IKeyValueMap<V> | any): ObservableMap<V> {
transaction(() => {
this.clear();
this.merge(values);
});
return this;
}

get size(): number {
return this._keys.length;
Expand Down
2 changes: 1 addition & 1 deletion src/types/observableobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export function defineComputedProperty(
compareStructural: boolean,
asInstanceProperty: boolean
) {
if (asInstanceProperty) // TODO: always false?
if (asInstanceProperty)
assertPropertyConfigurable(adm.target, propName);

adm.values[propName] = new ComputedValue(getter, adm.target, compareStructural, `${adm.name}.${propName}`, setter);
Expand Down
8 changes: 0 additions & 8 deletions src/types/observablevalue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ export interface IValueWillChange<T> {
newValue: T;
}

// TODO: Introduce in 4.0
// export interface IValueDidChange<T> {
// object: any;
// type: "update" | "create";
// newValue: T;
// oldValue: T;
// }

export type IUNCHANGED = {};

export const UNCHANGED: IUNCHANGED = {};
Expand Down
5 changes: 3 additions & 2 deletions src/utils/iterable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export interface Iterator<T> {
}

export function arrayAsIterator<T>(array: T[]): T[] & Iterator<T> {
// TODO: this should be removed in the next major version of MobX
// returning an array for entries(), values() etc for maps was a mis-interpretation of the specs..
// returning an array for entries(), values() etc for maps was a mis-interpretation of the specs..,
// yet it is quite convenient to be able to use the response both as array directly and as iterator
// it is suboptimal, but alas...
invariant(array[IS_ITERATING_MARKER] !== true, "Illegal state: cannot recycle array as iterator");
addHiddenFinalProp(array, IS_ITERATING_MARKER, true);

Expand Down
1 change: 0 additions & 1 deletion src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ export function deepEquals(a, b) {
}

export function createInstanceofPredicate<T>(name: string, clazz: new (...args: any[]) => T): (x: any) => x is T {
// TODO: this is quite a slow aproach, find something faster?
const propName = "isMobX" + name;
clazz.prototype[propName] = true;
return function (x) {
Expand Down
2 changes: 1 addition & 1 deletion test/babel/babel-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ test('decorators', function(t) {
var o = new Order();
t.equal(isObservableObject(o), true);
t.equal(isObservable(o, 'amount'), true);
t.equal(o.total, 6); // TODO: remove hmm this is required to initialize the props which are made reactive lazily..
t.equal(o.total, 6); // .... this is required to initialize the props which are made reactive lazily...
t.equal(isObservable(o, 'total'), true);

var events = [];
Expand Down
2 changes: 1 addition & 1 deletion test/extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ test('get debug name', function(t) {

t.equal(name(a), "ObservableValue@1");

t.equal(name(b, "a"), "[email protected]"); // TODO: remove @3..! (also in the other tests)
t.equal(name(b, "a"), "[email protected]");
t.throws(() => name(b, "b"), /no observable property 'b' found on the observable object 'ObservableObject@2'/, "expected throw");

t.equal(name(c), "ObservableMap@3"); // returns ke, "bla"ys
Expand Down
4 changes: 4 additions & 0 deletions test/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ test('observe value', function(t) {
a.merge({y: 'hello'});
t.equal(valueY, 'hello');

a.replace({ y: "stuff", z: "zoef"});
t.equal(valueY, "stuff");
t.deepEqual(a.keys(), ["y", "z"])

t.end();
})

Expand Down
1 change: 0 additions & 1 deletion test/observables.js
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,6 @@ test('unoptimizable subscriptions are diffed correctly', t => {

})

// TODO: revisit this test after estabilishing desired behaviour
test('atom events #427', t => {
var start = 0;
var stop = 0;
Expand Down
1 change: 0 additions & 1 deletion test/perf/perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ function order_system_helper(t, usebatch, keepObserving) {
return sum;
});

// TODO: use extendObservable!
function OrderLine(order, price, amount) {
this.price = observable(price);
this.amount = observable(amount);
Expand Down

0 comments on commit 6eb5b00

Please sign in to comment.