How to use resourcesSubject method in stryker-parent

Best JavaScript code snippet using stryker-parent

pool.ts

Source:pool.ts Github

copy

Full Screen

1import { TestRunner } from '@stryker-mutator/api/test-runner';2import { notEmpty } from '@stryker-mutator/util';3import { BehaviorSubject, filter, ignoreElements, lastValueFrom, mergeMap, Observable, ReplaySubject, Subject, takeUntil, tap, zip } from 'rxjs';4import { Disposable, tokens } from 'typed-inject';5import { CheckerFacade } from '../checker/index.js';6import { coreTokens } from '../di/index.js';7const MAX_CONCURRENT_INIT = 2;8/**9 * Represents a TestRunner that is also a Resource (with an init and dispose)10 */11export type TestRunnerResource = Resource & TestRunner;12export interface Resource extends Partial<Disposable> {13 init?(): Promise<void>;14}15createTestRunnerPool.inject = tokens(coreTokens.testRunnerFactory, coreTokens.testRunnerConcurrencyTokens);16export function createTestRunnerPool(factory: () => TestRunnerResource, concurrencyToken$: Observable<number>): Pool<TestRunner> {17 return new Pool(factory, concurrencyToken$);18}19createCheckerPool.inject = tokens(coreTokens.checkerFactory, coreTokens.checkerConcurrencyTokens);20export function createCheckerPool(factory: () => CheckerFacade, concurrencyToken$: Observable<number>): Pool<CheckerFacade> {21 return new Pool<CheckerFacade>(factory, concurrencyToken$);22}23/**24 * Represents a work item: an input with a task and with a `result$` observable where the result (exactly one) will be streamed to.25 */26class WorkItem<TResource extends Resource, TIn, TOut> {27 private readonly resultSubject = new Subject<TOut>();28 public readonly result$ = this.resultSubject.asObservable();29 /**30 * @param input The input to the ask31 * @param task The task, where a resource and input is presented32 */33 constructor(private readonly input: TIn, private readonly task: (resource: TResource, input: TIn) => Promise<TOut> | TOut) {}34 public async execute(resource: TResource) {35 try {36 const output = await this.task(resource, this.input);37 this.resultSubject.next(output);38 this.resultSubject.complete();39 } catch (err) {40 this.resultSubject.error(err);41 }42 }43 public reject(error: unknown) {44 this.resultSubject.error(error);45 }46 public complete() {47 this.resultSubject.complete();48 }49}50/**51 * Represents a pool of resources. Use `schedule` to schedule work to be executed on the resources.52 * The pool will automatically recycle the resources, but will make sure only one task is executed53 * on one resource at any one time. Creates as many resources as the concurrency tokens allow.54 * Also takes care of the initialing of the resources (with `init()`)55 */56export class Pool<TResource extends Resource> implements Disposable {57 // The init subject. Using an RxJS subject instead of a promise, so errors are silently ignored when nobody is listening58 private readonly initSubject = new ReplaySubject<void>();59 // The disposedSubject emits true when it is disposed, and false when not disposed yet60 private readonly disposedSubject = new BehaviorSubject(false);61 // The dispose$ only emits one `true` value when disposed (never emits `false`). Useful for `takeUntil`62 private readonly dispose$ = this.disposedSubject.pipe(filter((isDisposed) => isDisposed));63 private readonly createdResources: TResource[] = [];64 // The queued work items. This is a replay subject, so scheduled work items can easily be rejected after it was picked up65 private readonly todoSubject = new ReplaySubject<WorkItem<TResource, any, any>>();66 constructor(factory: () => TResource, concurrencyToken$: Observable<number>) {67 // Stream resources that are ready to pick up work68 const resourcesSubject = new Subject<TResource>();69 // Stream ongoing work.70 zip(resourcesSubject, this.todoSubject)71 .pipe(72 mergeMap(async ([resource, workItem]) => {73 await workItem.execute(resource);74 resourcesSubject.next(resource); // recycle resource so it can pick up more work75 }),76 ignoreElements(),77 takeUntil(this.dispose$)78 )79 .subscribe({80 error: (error) => {81 this.todoSubject.subscribe((workItem) => workItem.reject(error));82 },83 });84 // Create resources85 concurrencyToken$86 .pipe(87 takeUntil(this.dispose$),88 mergeMap(async () => {89 if (this.disposedSubject.value) {90 // Don't create new resources when disposed91 return;92 }93 const resource = factory();94 this.createdResources.push(resource);95 await resource.init?.();96 return resource;97 }, MAX_CONCURRENT_INIT),98 filter(notEmpty),99 tap({100 complete: () => {101 // Signal init complete102 this.initSubject.next();103 this.initSubject.complete();104 },105 error: (err) => {106 this.initSubject.error(err);107 },108 })109 )110 .subscribe({111 next: (resource) => resourcesSubject.next(resource),112 error: (err) => resourcesSubject.error(err),113 });114 }115 /**116 * Returns a promise that resolves if all concurrency tokens have resulted in initialized resources.117 * This is optional, resources will get initialized either way.118 */119 public async init(): Promise<void> {120 await lastValueFrom(this.initSubject);121 }122 /**123 * Schedules a task to be executed on resources in the pool. Each input is paired with a resource, which allows async work to be done.124 * @param input$ The inputs to pair up with a resource.125 * @param task The task to execute on each resource126 */127 public schedule<TIn, TOut>(input$: Observable<TIn>, task: (resource: TResource, input: TIn) => Promise<TOut> | TOut): Observable<TOut> {128 return input$.pipe(129 mergeMap((input) => {130 const workItem = new WorkItem(input, task);131 this.todoSubject.next(workItem);132 return workItem.result$;133 })134 );135 }136 /**137 * Dispose the pool138 */139 public async dispose(): Promise<void> {140 if (!this.disposedSubject.value) {141 this.disposedSubject.next(true);142 this.todoSubject.subscribe((workItem) => workItem.complete());143 this.todoSubject.complete();144 await Promise.all(this.createdResources.map((resource) => resource.dispose?.()));145 }146 }...

Full Screen

Full Screen

index.jsx

Source:index.jsx Github

copy

Full Screen

1import React, { Component } from 'react';2import uuid from 'uuid'; // eslint-disable-line3import PropTypes from 'prop-types';4import './resourcesSubject.css';5import Resource from './Resource';6import InputLink from './InputLink';7import ResourcesHeader from './ResourcesHeader';8import Message from './../../../../common/Message';9const propTypes = {10 activeSubject: PropTypes.shape({11 name: PropTypes.string,12 links: PropTypes.arrayOf(PropTypes.object),13 }).isRequired,14 textInputLink: PropTypes.string.isRequired,15 openInputLink: PropTypes.bool.isRequired,16 handleOpenInputLink: PropTypes.func.isRequired,17 handleCloseInputLink: PropTypes.func.isRequired,18 handleAddNewLink: PropTypes.func.isRequired,19 handleFavorites: PropTypes.func.isRequired,20 handleDeleteLink: PropTypes.func.isRequired,21 handleValueInputLink: PropTypes.func.isRequired,22};23class ResourcesSubject extends Component {24 constructor(props) {25 super(props);26 this.state = {};27 }28 // Get favorites links29 getLinksFavorites() {30 const listFavorites = this.props.activeSubject.links31 .filter(link => ((!link.isDeleted) ? link.isFavorite : false));32 return listFavorites;33 }34 // Get others links (no favorites)35 getOthersLinks() {36 const othersLinks = this.props.activeSubject.links37 .filter(link => ((!link.isDeleted) ? !link.isFavorite : false));38 return othersLinks;39 }40 // ******************** RENDER ******************** //41 // Render input Links42 renderInputLink() { // eslint-disable-line43 if (this.props.openInputLink) {44 return (45 <InputLink46 textInputLink={this.props.textInputLink}47 handleCloseInputLink={this.props.handleCloseInputLink}48 handleAddNewLink={this.props.handleAddNewLink}49 handleValueInputLink={this.props.handleValueInputLink}50 />51 );52 }53 }54 // Render favorites55 renderLinksFavorites() {56 const linksFavorites = this.getLinksFavorites();57 if (linksFavorites.length === 0) {58 return (59 <Message message="No tienes links favoritos!" />60 );61 }62 return linksFavorites.map(favorite => (63 <Resource64 key={favorite.id}65 link={favorite}66 handleFavorites={this.props.handleFavorites}67 handleDeleteLink={this.props.handleDeleteLink}68 />69 ));70 }71 // Render others links (no favorites)72 renderOthersLinks() {73 const othersLinks = this.getOthersLinks();74 return othersLinks.map(resource => (75 <Resource76 key={resource.id}77 link={resource}78 handleFavorites={this.props.handleFavorites}79 handleDeleteLink={this.props.handleDeleteLink}80 />81 ));82 }83 renderLinks() {84 const links = this.props.activeSubject.links.filter(link => !link.isDeleted);85 if (links.length > 0) {86 return (87 <div>88 <div>89 <div className="favorites-container">90 <span> Favoritos </span>91 </div>92 {this.renderLinksFavorites()}93 </div>94 {95 (this.getOthersLinks().length > 0)96 ?97 <div>98 <div className="others-container">99 <span> Otros </span>100 </div>101 {this.renderOthersLinks()}102 </div>103 : false104 }105 </div>106 );107 }108 return (109 <Message message="No existen links para este tema, adiciona uno nuevo!" />110 );111 }112 render() {113 return (114 <div className="resources-container">115 <ResourcesHeader116 activeSubject={this.props.activeSubject}117 handleOpenInputLink={this.props.handleOpenInputLink}118 />119 {this.renderInputLink()}120 {this.renderLinks()}121 </div>122 );123 }124}125ResourcesSubject.propTypes = propTypes;...

Full Screen

Full Screen

photo.datasource.ts

Source:photo.datasource.ts Github

copy

Full Screen

1import {Injectable} from '@angular/core';2import { environment } from '../../../environments/environment';3import {CollectionViewer, DataSource} from '@angular/cdk/collections';4import {Observable} from 'rxjs/Observable';5import {HttpClient, HttpParams} from '@angular/common/http';6import {BehaviorSubject} from 'rxjs/BehaviorSubject';7import {map, catchError, finalize} from 'rxjs/operators';8import {of} from 'rxjs/observable/of';9import {Photo} from '../../model/photo/photo.model';10// @todo: refactor this by making a generic superclass11// @todo: unused class, check for deletion12@Injectable()13export class PhotoDataSource implements DataSource<Photo> {14 // The array of Occurrence instances retrieved from the Web service:15 public resourcesSubject = new BehaviorSubject<Photo[]>([]);16 private loadingSubject = new BehaviorSubject<boolean>(false);17 public loading$ = this.loadingSubject.asObservable();18 private resourceUrl = environment.api.baseUrl + '/photos';19 constructor(private http: HttpClient) {20 }21 find(sortProperty = '', sortOrder = 'asc',22 pageNumber = 0, pageSize = 3): Observable<Photo[]> {23 return this.http.get<Photo[]>(this.resourceUrl + '.json', {24 params: new HttpParams()25 // .set('filter', filter)26 .set('orderBy', sortProperty)27 .set('sortOrder', sortOrder)28 .set('pageNumber', pageNumber.toString())29 .set('pageSize', pageSize.toString())30 });31 }32 load(sortProperty: string,33 sortDirection: string,34 pageIndex: number,35 pageSize: number) {36 this.loadingSubject.next(true);37 this.find(sortProperty, sortDirection,38 pageIndex, pageSize).pipe(39 catchError(() => of([])),40 finalize(() => this.loadingSubject.next(false))41 )42 .subscribe(resources => {43 this.resourcesSubject.next(resources);44 });45 }46 connect(collectionViewer: CollectionViewer): Observable<Photo[]> {47 console.log('Connecting data source');48 return this.resourcesSubject.asObservable();49 }50 disconnect(collectionViewer: CollectionViewer): void {51 this.resourcesSubject.complete();52 this.loadingSubject.complete();53 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var parent = require('stryker-parent');2var resourcesSubject = parent.resourcesSubject;3resourcesSubject('test');4var parent = require('stryker-parent');5var resourcesSubject = parent.resourcesSubject;6resourcesSubject('test2');7var parent = require('stryker-parent');8var resourcesSubject = parent.resourcesSubject;9resourcesSubject('test3');10var parent = require('stryker-parent');11var resourcesSubject = parent.resourcesSubject;12resourcesSubject('test4');13var parent = require('stryker-parent');14var resourcesSubject = parent.resourcesSubject;15resourcesSubject('test5');16var parent = require('stryker-parent');17var resourcesSubject = parent.resourcesSubject;18resourcesSubject('test6');19var parent = require('stryker-parent');20var resourcesSubject = parent.resourcesSubject;21resourcesSubject('test7');22var parent = require('stryker-parent');23var resourcesSubject = parent.resourcesSubject;24resourcesSubject('test8');25var parent = require('stryker-parent');26var resourcesSubject = parent.resourcesSubject;27resourcesSubject('test9');28var parent = require('stryker-parent');29var resourcesSubject = parent.resourcesSubject;30resourcesSubject('test10');31var parent = require('stryker-parent');32var resourcesSubject = parent.resourcesSubject;33resourcesSubject('test11');34var parent = require('stryker-parent');35var resourcesSubject = parent.resourcesSubject;36resourcesSubject('test12');

Full Screen

Using AI Code Generation

copy

Full Screen

1var resourcesSubject = require('stryker-parent').resourcesSubject;2var resource = resourcesSubject('test');3console.log(resource);4var resourcesSubject = require('stryker-parent').resourcesSubject;5var resource = resourcesSubject('test');6console.log(resource);7var resourcesSubject = require('stryker-parent').resourcesSubject;8var resource = resourcesSubject('test');9console.log(resource);10var resourcesSubject = require('stryker-parent').resourcesSubject;11var resource = resourcesSubject('test');12console.log(resource);13var resourcesSubject = require('stryker-parent').resourcesSubject;14var resource = resourcesSubject('test');15console.log(resource);16var resourcesSubject = require('stryker-parent').resourcesSubject;17var resource = resourcesSubject('test');18console.log(resource);19var resourcesSubject = require('stryker-parent').resourcesSubject;20var resource = resourcesSubject('test');21console.log(resource);22var resourcesSubject = require('stryker-parent').resourcesSubject;23var resource = resourcesSubject('test');24console.log(resource);25var resourcesSubject = require('stryker-parent').resourcesSubject;26var resource = resourcesSubject('test');27console.log(resource);28var resourcesSubject = require('stryker-parent').resourcesSubject;29var resource = resourcesSubject('test');30console.log(resource);31var resourcesSubject = require('stryker-parent').resourcesSubject;32var resource = resourcesSubject('test');33console.log(resource);34var resourcesSubject = require('stryker-parent').resourcesSubject;

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2var subject = stryker.resourcesSubject();3subject.next({4});5var stryker = require('stryker-parent');6var subject = stryker.resourcesSubject();7subject.next({8});9var stryker = require('stryker-parent');10var subject = stryker.resourcesSubject();11subject.next({12});13var stryker = require('stryker-parent');14var subject = stryker.resourcesSubject();15subject.next({16});17var stryker = require('stryker-parent');18var subject = stryker.resourcesSubject();19subject.next({20});21var stryker = require('stryker-parent');22var subject = stryker.resourcesSubject();23subject.next({24});25var stryker = require('stryker-parent');26var subject = stryker.resourcesSubject();27subject.next({28});29var stryker = require('stryker-parent');

Full Screen

Using AI Code Generation

copy

Full Screen

1var subject = require('stryker-parent').resourcesSubject;2var expected = 'expected';3var actual = subject();4assert.equal(actual, expected);5var subject = require('stryker-parent').resourcesSubject;6var expected = 'expected';7var actual = subject();8assert.equal(actual, expected);9var subject = require('stryker-parent').resourcesSubject;10var expected = 'expected';11var actual = subject();12assert.equal(actual, expected);13var subject = require('stryker-parent').resourcesSubject;14var expected = 'expected';15var actual = subject();16assert.equal(actual, expected);17var subject = require('stryker-parent').resourcesSubject;18var expected = 'expected';19var actual = subject();20assert.equal(actual, expected);21var subject = require('stryker-parent').resourcesSubject;22var expected = 'expected';23var actual = subject();24assert.equal(actual, expected);25var subject = require('stryker-parent').resourcesSubject;26var expected = 'expected';27var actual = subject();28assert.equal(actual, expected);29var subject = require('stryker-parent').resourcesSubject;30var expected = 'expected';31var actual = subject();32assert.equal(actual, expected);33var subject = require('stryker-parent').resourcesSubject;34var expected = 'expected';35var actual = subject();36assert.equal(actual, expected);37var subject = require('stryker-parent').resourcesSubject;38var expected = 'expected';39var actual = subject();40assert.equal(actual, expected);41var subject = require('stryker-parent').resourcesSubject;42var expected = 'expected';

Full Screen

Using AI Code Generation

copy

Full Screen

1var resourcesSubject = require('stryker-parent').resourcesSubject;2var Rx = require('rx');3var subject = resourcesSubject();4subject.subscribe(function (message) {5 console.log(message);6});7subject.onNext('Hello World');8subject.onCompleted();9var resourcesSubject = require('stryker-parent').resourcesSubject;10var Rx = require('rx');11var subject = resourcesSubject();12subject.subscribe(function (message) {13 console.log(message);14});15subject.onNext('Hello World');16subject.onCompleted();

Full Screen

Using AI Code Generation

copy

Full Screen

1const resourcesSubject = require('@stryker-mutator/core').resourcesSubject;2const resources = require('./resources');3resourcesSubject.subscribe(resources);4const resourcesSubject = require('@stryker-mutator/core').resourcesSubject;5const resources = require('./resources');6resourcesSubject.subscribe(resources);7const resourcesSubject = require('@stryker-mutator/core').resourcesSubject;8const resources = require('./resources');9resourcesSubject.subscribe(resources);10const resourcesSubject = require('@stryker-mutator/core').resourcesSubject;11const resources = require('./resources');12resourcesSubject.subscribe(resources);13const resourcesSubject = require('@stryker-mutator/core').resourcesSubject;14const resources = require('./resources');15resourcesSubject.subscribe(resources);16const resourcesSubject = require('@stryker-mutator/core').resourcesSubject;17const resources = require('./resources');18resourcesSubject.subscribe(resources);19const resourcesSubject = require('@stryker-mutator/core').resourcesSubject;20const resources = require('./resources');21resourcesSubject.subscribe(resources);22const resourcesSubject = require('@stryker-mutator/core').resourcesSubject;23const resources = require('./resources');24resourcesSubject.subscribe(resources);25const resourcesSubject = require('@stryker-mutator/core').resourcesSubject;26const resources = require('./resources');27resourcesSubject.subscribe(resources);

Full Screen

Using AI Code Generation

copy

Full Screen

1var parent = require('stryker-parent');2var stryker = new parent.Stryker();3stryker.resourcesSubject.subscribe(function (files) {4 console.log(files);5});6stryker.run();7module.exports = function (config) {8 config.set({9 karma: {10 },11 });12};13module.exports = function (config) {14 config.set({15 });16};17module.exports = {18 ['@babel/preset-env', {19 targets: {20 }21 }]22};23module.exports = function (config) {24 config.set({25 karma: {26 },

Full Screen

Using AI Code Generation

copy

Full Screen

1const resourceSubject = require('stryker-parent').resourcesSubject;2const resource = resourceSubject('resources');3console.log(resource);4const resourceSubject = require('stryker-parent').resourcesSubject;5const resource = resourceSubject('resources');6console.log(resource);7const resourceSubject = require('stryker-parent').resourcesSubject;8const resource = resourceSubject('resources');9console.log(resource);10const resourceSubject = require('stryker-parent').resourcesSubject;11const resource = resourceSubject('resources');12console.log(resource);13const resourceSubject = require('stryker-parent').resourcesSubject;14const resource = resourceSubject('resources');15console.log(resource);16const resourceSubject = require('stryker-parent').resourcesSubject;17const resource = resourceSubject('resources');18console.log(resource);19const resourceSubject = require('stryker-parent').resourcesSubject;20const resource = resourceSubject('resources');21console.log(resource);22const resourceSubject = require('stryker-parent').resourcesSubject;23const resource = resourceSubject('resources');24console.log(resource);25const resourceSubject = require('stryker-parent').resourcesSubject;26const resource = resourceSubject('resources');27console.log(resource);28const resourceSubject = require('stryker-parent').resourcesSubject;29const resource = resourceSubject('resources');30console.log(resource);31const resourceSubject = require('stryker-parent').resourcesSubject;32const resource = resourceSubject('resources');33console.log(resource);34const resourceSubject = require('stryker-parent').resourcesSubject;35const resource = resourceSubject('resources');36console.log(resource);37const resourceSubject = require('stry

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful