- React only on action of page entering with the correct page id
- Check URL parameters to obtain the current entry id
- Emit action for setting the current selected entry id in the state data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Observable } from 'rxjs/Observable'; | |
import { Subscription } from 'rxjs/Subscription'; | |
import 'rxjs/add/operator/delay'; | |
/** | |
* An helper class to assert if an Observer produces the specified values. | |
* It does not care about the time between values produced by the observer. | |
* Returns a promise that either completes if test passed ok, or reject with an error message if not. | |
* @param obs$ The observer to test. | |
* @param values The array of values to expect in the observable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EntrySer { | |
constructor( | |
public id: string = null, | |
public title: string = '', | |
public type: string = 'FLICKR', | |
public data: string = '', | |
public postBy: UserRef = null, | |
public dateCreated: string = null) { } | |
public static fields: string = ` |
- React only on any action of types:
- Selection of an entry. An entry was just selected so we should try to load its data.
- User login success. Since an entry may be selected but not a user, only after the user is ok we can try to load the entry.
- Page load. Similar to the user login check. Only on the correct page we can load the entry.
- React only on these pre-condition:
- Correct page id
- user logged in
- If current selected entry id is null:
- Chain an action setting editing status to READY
- Set editing data to empty