clean state cache in 30 seconds
This commit is contained in:
		
							
								
								
									
										18
									
								
								readme.md
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								readme.md
									
									
									
									
									
								
							| @ -8,7 +8,7 @@ All you need to do is: | |||||||
| - Find out the selectors for target data | - Find out the selectors for target data | ||||||
| - Type scripts in the console of `extension backgroud page`, as introduced bellow. | - Type scripts in the console of `extension backgroud page`, as introduced bellow. | ||||||
|  |  | ||||||
|   |   | ||||||
|  |  | ||||||
| ## Qucik Start | ## Qucik Start | ||||||
|  |  | ||||||
| @ -52,10 +52,7 @@ function (itemsSelector:string, fieldSelectors:string[], urls:ExtractResult) | |||||||
|  |  | ||||||
| ## Stop Tasks | ## Stop Tasks | ||||||
|  |  | ||||||
| The only way to stop tasks before its finish, is `Closing the target tab`. | Close the target tab, in which current tasks is running. | ||||||
|  |  | ||||||
| > Tasks wait for their target elements' appearance, given some elements were loaded asynchronously.   |  | ||||||
| > If you typed wrong selectors, the task waits forever for  elements which don't exists. |  | ||||||
|  |  | ||||||
| ## Extract Attributes. | ## Extract Attributes. | ||||||
|  |  | ||||||
| @ -126,17 +123,17 @@ e.export(1) | |||||||
|  |  | ||||||
| Sometimes, it's hard to finish them in an single execution, that why we need "Continuing of Tasks". | Sometimes, it's hard to finish them in an single execution, that why we need "Continuing of Tasks". | ||||||
|  |  | ||||||
| You can always continue tasks (with following), even it stops in the middle of a task: | You can always continue tasks by start it again, not matter in what phase it stops. | ||||||
|  |  | ||||||
| ```js | ```js | ||||||
| e.start() | e.start() | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| The `Extractor` kept the state of last execution, and starts from where it stopped. | The `Extractor` kept the execution state, and starts from where it stopped. | ||||||
|  |  | ||||||
| ### Restart Tasks | ### Restart Tasks | ||||||
|  |  | ||||||
| What should I do, if I don't like to continue from last state, but restart from certain task? | What if I don't like to continue from last state, but restart certain tasks? | ||||||
|  |  | ||||||
| ```js | ```js | ||||||
| // restart all tasks | // restart all tasks | ||||||
| @ -166,12 +163,15 @@ e.save(); | |||||||
|  |  | ||||||
| Load the state: | Load the state: | ||||||
|  |  | ||||||
| Open the popup window, upload the saved state file. Then, and in the backgoud console: | Open the popup window, upload the saved state file. Then, and in the backgroud console: | ||||||
|  |  | ||||||
| ```js | ```js | ||||||
| e = new Extractor().load(); | e = new Extractor().load(); | ||||||
|  | e.start(); | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|  | > The uploaded state will be cleaned in 30 seconds, if you don't load it. | ||||||
|  |  | ||||||
| ## Developpment | ## Developpment | ||||||
|  |  | ||||||
| Clone this project and execute: | Clone this project and execute: | ||||||
|  | |||||||
| @ -11,5 +11,12 @@ export class Caches { | |||||||
|     setState(name: string, content: string) { |     setState(name: string, content: string) { | ||||||
|         this._state = content; |         this._state = content; | ||||||
|         logger.info(`State (${name}) recieved. To load it: some_var = new Extractor().load()`); |         logger.info(`State (${name}) recieved. To load it: some_var = new Extractor().load()`); | ||||||
|  |         // clear cache in 30 seconds | ||||||
|  |         setTimeout(() => { | ||||||
|  |             if (this._state) { | ||||||
|  |                 logger.info(`Uploaded state is cleaned after 30 second.`); | ||||||
|  |                 this._state = ""; | ||||||
|  |             } | ||||||
|  |         }, 30000); | ||||||
|     } |     } | ||||||
| } | } | ||||||
		Reference in New Issue
	
	Block a user