How to use reactn - 10 common examples

To help you get started, we’ve selected a few reactn 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 Graphite-Docs / graphite / web / src / components / helpers / sharedVaultFiles.js View on Github external
export function saveNewVaultTwo() {
  const file = window.location.href.split('shared/')[1].split('/')[1].split('#')[0] + '.json';
  putFile(file, JSON.stringify(getGlobal().singleFile), {encrypt:true})
    .then(() => {
      console.log("Saved!");
      saveVaultCollection();
      // window.location.replace("/vault");
    })
    .catch(e => {
      console.log("e");
      console.log(e);

    });
}
github Graphite-Docs / graphite / web / src / components / helpers / contacts.js View on Github external
export function filterContactsNow() {
    const global = getGlobal();
    let contacts = global.contacts;

    if(global.selectedType !== "") {
      let typeFilter = contacts.filter(x => typeof x.types !== 'undefined' ? x.types.includes(global.selectedType) : console.log("nada"));
      // let typeFilter = contacts.filter(x => x.types.includes(global.selectedType));
      setGlobal({ filteredContacts: typeFilter, appliedFilter: true});
      window.$('.button-collapse').sideNav('hide');
    } else if (global.selectedDate !== "") {
      let dateFilter = contacts.filter(x => typeof x.dateAdded !== 'undefined' ? x.dateAdded.includes(global.selectedDate) : console.log("nada"));
      // let dateFilter = contacts.filter(x => x.dateAdded.includes(global.selectedDate));
      setGlobal({ filteredContacts: dateFilter, appliedFilter: true});
      window.$('.button-collapse').sideNav('hide');
    }
  }
github Graphite-Docs / graphite / web / src / components / helpers / contacts.js View on Github external
export function saveNewTypes() {
    const global = getGlobal();
    console.log(global.index);
    setGlobal({ loading: true })
    const object = {};
    object.contact = global.contact;
    object.name = global.name;
    object.dateAdded = global.dateAdded;
    object.types = global.types;
    object.img = global.newContactImg;
    const index = global.index;
    const updatedContact = update(global.contacts, {$splice: [[index, 1, object]]});
    setGlobal({contacts: updatedContact, filteredContacts: updatedContact }, () => {
      saveNewContactsFile();
    });
    // setTimeout(saveFullCollectionTypes, 500);
  }
github Graphite-Docs / graphite / src / components / contacts / helpers / contacts.js View on Github external
export function filterContactsNow() {
  const global = getGlobal();
  let contacts = global.contacts;

  if (global.selectedType !== "") {
    let typeFilter = contacts.filter(x =>
      typeof x.types !== "undefined"
        ? x.types.includes(global.selectedType)
        : console.log("nada")
    );
    // let typeFilter = contacts.filter(x => x.types.includes(global.selectedType));
    setGlobal({ filteredContacts: typeFilter, appliedFilter: true });
    window.$(".button-collapse").sideNav("hide");
  } else if (global.selectedDate !== "") {
    let dateFilter = contacts.filter(x =>
      typeof x.dateAdded !== "undefined"
        ? x.dateAdded.includes(global.selectedDate)
        : console.log("nada")
github Graphite-Docs / graphite / src / components / files / helpers / publicVault.js View on Github external
.then(result => {
                var html = result.value; // The generated HTML
                setGlobal({ content: html });
                console.log(getGlobal().content);
                setGlobal({ loading: false });
                })
                .done();
github Graphite-Docs / graphite / web / src / components / helpers / publicVault.js View on Github external
.then(result => {
                var html = result.value; // The generated HTML
                setGlobal({ content: html });
                console.log(getGlobal().content);
                setGlobal({ loading: false });
              })
              .done();
github Graphite-Docs / graphite / web / src / components / helpers / deleteVaultFile.js View on Github external
export function saveVaultDeleteTwo(file) {
  const fileID = file.id;
  putFile(fileID + '.json', JSON.stringify(getGlobal().singleFile), {encrypt:true})
    .then(() => {
      console.log("Saved!");
      // setGlobal({loading: false});
      loadVault();
    })
    .catch(e => {
      console.log("e");
      console.log(e);
      alert(e.message);
    });
}
github Graphite-Docs / graphite / src / components / forms / helpers / singleForm.js View on Github external
export async function shareWithTeam(data) {
    console.log(data);
    if(data.fromSave) {
      //Nothing
    } else {
      setGlobal({ teamShare: true });
    }
    const { userSession, proOrgInfo } = getGlobal();
    //First we need to fetch the teamKey
    const teamKeyParams = {
      fileName: `user/${userSession.loadUserData().username.split('.').join('_')}/team/${data.teamId}/key.json`,
      decrypt: true
    }
    const fetchedKeys = await fetchData(teamKeyParams);
    let singleForm = getGlobal().singleForm;
    const form = {
      id: singleForm.id,
      team: data.teamId,
      orgId: proOrgInfo.orgId,
      title: singleForm.title,
      responses: singleForm.responses || getGlobal().formResponses,
      currentHostBucket: userSession.loadUserData().username
    }
    const encryptedTeamForm = userSession.encryptContent(JSON.stringify(form), {publicKey: JSON.parse(fetchedKeys).public})
github Graphite-Docs / graphite / src / components / files / helpers / singleVaultFile.js View on Github external
export async function saveFile() {
    let singleFile = await getGlobal().singleFile;
    let singleFileParams = {
        fileName: `${window.location.href.split('files/')[1]}.json`,
        encrypt: true,
        body: JSON.stringify(singleFile)
    }
    const postedFile = await postData(singleFileParams);
    console.log(postedFile);
    await saveIndex();
  }
github Graphite-Docs / graphite / src / components / forms / helpers / singleForm.js View on Github external
currentHostBucket: userSession.loadUserData().username
    }
    const encryptedTeamForm = userSession.encryptContent(JSON.stringify(form), {publicKey: JSON.parse(fetchedKeys).public})

    const teamForm = {
      fileName: `teamForms/${data.teamId}/${singleForm.id}.json`,
      encrypt: false,
      body: JSON.stringify(encryptedTeamForm)
    }
    const postedTeamForm = await postData(teamForm);
    console.log(postedTeamForm);

    singleForm["teamForm"] = true;
    let theseTeams = singleForm.teams;
    singleForm.teams.includes(data.teamId) ? singleForm.teams = theseTeams : singleForm.teams.push(data.teamId);
    await setGlobal({ singleForm });
    if(data.fromSave) {
      //Do nothing
    } else {
      await saveForm(false);
    }

    const privateKey = userSession.loadUserData().appPrivateKey;

    const syncedForm = {
      id: singleForm.id,
      title: userSession.encryptContent(singleForm.title, {publicKey: JSON.parse(fetchedKeys).public}),
      teamName: data.teamName ? userSession.encryptContent(data.teamName, {publicKey: JSON.parse(fetchedKeys).public}) : "",
      orgId: proOrgInfo.orgId,
      teamId: data.teamId,
      lastUpdated: getMonthDayYear(),
      timestamp: Date.now(),

reactn

React, but with built-in global state management.

MIT
Latest version published 5 years ago

Package Health Score

51 / 100
Full package analysis

Popular reactn functions