How to use the kefir.zip function in kefir

To help you get started, we’ve selected a few kefir examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github researchspace / researchspace / researchspace / web / src / main / components / iiif / SideBySideComparison.ts View on Github external
return ImageApi.queryImageBounds(serviceUrl, imageInfo.imageId).flatMap(bounds =>
        // we've got image size, we can create manifest
        // but instead we are starting to fetch for regions
          LdpRegionService.search(imageInfo.imageIRI).flatMap(annotations =>
            // and lastly we're creating manifest and putting it all together
            createManifest([{
              baseIri: imageInfo.iri,
              imageIri: imageInfo.imageIRI,
              imageServiceUri: serviceRequestUri,
              canvasSize: bounds,
            }]).map(manifest => ({manifest, imageInfo, annotations}))
          )
        );
      }));

    return Kefir.zip(metadataTasks);
  }
github mAAdhaTTah / brookjs / packages / brookjs-desalinate / src / __tests__ / jestPlugin.spec.tsx View on Github external
const delta: Delta = (action$, state$) =>
      Kefir.zip([action$, state$]).flatMap(respond);
github researchspace / researchspace / metaphacts-platform / web / src / main / components / workflow / WorkflowManagerComponent.tsx View on Github external
private onSubmit = () => {
    this.setState({status: Status.Updating});
    const workflowsUpdating = this.props.iris.map(iri => {
      const {workflowState} = this.state;
      const originalGraph = this.originalWorkflowGraphs.get(iri);
      return this.workflowService.updateWorkflowInstantiation({
        workflowIri: Rdf.iri(iri),
        originalGraph,
        workflowState,
      });
    });
    this.cancellation.map(
      Kefir.zip(workflowsUpdating)
    ).observe({
      value: () => {
        this.setState({status: Status.Ready});
        addNotification({
          level: 'success',
          message: 'The workflow instantiations has been updated.',
        });
        this.fetchWorkflowInstantiations(this.props);
      },
      error: error => {
        console.error(error);
        this.setState({status: Status.Ready});
        addNotification({
          level: 'error',
          message: 'Error occurred while updating the workflow instantiations.',
        });
github researchspace / researchspace / researchspace / web / src / main / components / panel-system / IIIFViewerPanel.tsx View on Github external
const querying = iris.map(iri => {
      const sparql = SparqlClient.setBindings(parsedQuery, {[BINDING_VARIABLE]: Rdf.iri(iri)});
      const requests = repositories.map(repository =>
        SparqlClient.select(sparql, {context: {repository}}).map(
          ({results}) => ({iri, images: results.bindings.map(({image}) => image.value)})
        )
      );
      return Kefir.zip(requests);
    });
    this.queryingCancellation = this.cancellation.deriveAndCancel(this.queryingCancellation);
github researchspace / researchspace / researchspace / web / src / main / components / iiif / ImageRegionEditor.ts View on Github external
const imageInfo = this.state.info.get(imageIri);
      const iiifImageId = this.state.iiifImageId.get(imageIri);
      if (!imageInfo || !iiifImageId) { return Kefir.constant(undefined); }
      const imageServiceUri = ImageApi.constructServiceRequestUri(iiifServerUrl, iiifImageId);
      return ImageApi.queryImageBounds(iiifServerUrl, iiifImageId).flatMap(canvasSize =>
        Kefir.constant({
          baseIri: imageInfo.isRegion ? imageInfo.imageIRI : Rdf.iri(iri),
          imageIri: imageInfo.imageIRI,
          imageServiceUri,
          canvasSize,
        })
      ).flatMapErrors(() =>
        Kefir.constant(undefined)
      );
    });
    return Kefir.zip(queryingImagesInfo).toProperty();
  }
github researchspace / researchspace / metaphacts-platform / web / src / main / components / forms / inputs / CompositeInput.ts View on Github external
function zipImmutableMap(
  map: Immutable.Map>
): Kefir.Property> {
  const mapAsArray = map.map((kefirValue, key) => {
    return kefirValue.map(value => ({key, value}));
  }).toArray();

  if (mapAsArray.length > 0) {
    return Kefir.zip(mapAsArray).map(values =>
      Immutable.Map().withMutations(newMap => {
        for (const {key, value} of values) {
          newMap.set(key, value);
        }
      })
    ).toProperty();
  } else {
    return Kefir.constant(Immutable.Map());
  }
}
github researchspace / researchspace / metaphacts-platform / web / src / main / components / forms / FormModel.ts View on Github external
function lookForDefaultValues(
  def: FieldDefinition, mapping: InputMapping
): Kefir.Property {
  const {defaultValue, defaultValues} = mapping.element.props;
  if (defaultValue || defaultValues) {
    const values = defaultValue ? [defaultValue] : defaultValues;
    const fieldValues = values.map(value => parseDefaultValue(value, def));
    if (fieldValues.length > 0) {
      return Kefir.zip(fieldValues).toProperty();
    }
  } else if (def.defaultValues.length > 0) {
    const fieldValues = def.defaultValues.map(value => parseDefaultValue(value, def));
    return Kefir.zip(fieldValues).toProperty();
  }
  return Kefir.constant([]);
}
github researchspace / researchspace / researchspace / web / src / main / data / iiif / ManifestBuilder.ts View on Github external
?canvasURI exif:width ?canvasWidth;
exif:height ?canvasHeight.
} WHERE {
  BIND(STR(${baseIri}) as ?baseStr)
  BIND(URI(CONCAT(?baseStr, "/manifest.json")) as ?manifestURI)
  BIND(URI(CONCAT(?baseStr, "/sequence")) as ?sequenceURI)
  BIND(STR(?imageIri) as ?imageStr)
  BIND(URI(CONCAT(?imageStr, "")) as ?canvasURI)
  BIND(URI(CONCAT(?imageStr, "/imageanno/anno-1")) as ?imageannoURI)
  BIND(URI(CONCAT(?imageStr, "/imgresource")) as ?imageResourceURI)
}`;
  const iris = params.map(({imageIri}) => imageIri);
  const queryingDisplayLabel = getLabel(baseIri);
  const queryingImagesLabels = getLabels(iris);
  return Kefir.zip([queryingDisplayLabel, queryingImagesLabels]).flatMap(
    ([displayLabel, labels]) => {
      const parameters = params.map(param => ({
        displayLabel: Rdf.literal(displayLabel),
        imageIri: param.imageIri,
        service: Rdf.iri(param.imageServiceUri),
        canvasWidth: Rdf.literal(param.canvasSize.width.toString(), xsd.integer),
        canvasHeight: Rdf.literal(param.canvasSize.height.toString(), xsd.integer),
        label: Rdf.literal(labels.get(param.imageIri)),
      }));
      return SparqlClient.prepareQuery(sparql, parameters);
    }
  ).map(query =>
    SparqlUtil.serializeQuery(query)
  ).toProperty();
}
github researchspace / researchspace / researchspace / web / src / main / components / iiif / OverlayComparison.ts View on Github external
loadState(props: Props) {
    const tasks = props.selection
      .map(iri => typeof iri === 'string' ? Rdf.iri(iri) : iri)
      .map(iri => queryIIIFImageOrRegion(iri, props.imageIdPattern, props.repositories));
    return Kefir.zip(tasks).map(metadata => ({
      metadata: Immutable.List(metadata),
    }));
  }

kefir

Reactive Programming library for JavaScript inspired by Bacon.js and RxJS with focus on high performance and low memory usage

MIT
Latest version published 4 years ago

Package Health Score

57 / 100
Full package analysis