How to use the pubsub-js.publish function in pubsub-js

To help you get started, we’ve selected a few pubsub-js 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 igorski / efflux-tracker / src / js / controller / AdvancedPatternEditorController.js View on Github external
const eventEnd    = event.seq.endMeasure;
                    const eventLength = isNaN( eventEnd ) ? 1 : eventEnd - eventStart;

                    event.seq.startMeasure = patternIndex;
                    event.seq.endMeasure   = event.seq.startMeasure + eventLength;
                }
            });
        });
    }

    Pubsub.publish( Messages.CREATE_LINKED_LISTS );

    // update UI

    Pubsub.publish( Messages.REFRESH_SONG );
    Pubsub.publish( Messages.PATTERN_AMOUNT_UPDATED );

    handleClose();
}
github AdChain / AdChainRegistryDapp / src / components / single_domain / DomainInRegistryContainer.js View on Github external
async withdrawListing () {
    const {domain} = this.state

    try {
      let transactionInfo = {
        src: 'withdraw_listing',
        title: 'Withdraw Listing'
      }

      PubSub.publish('TransactionProgressModal.open', transactionInfo)
      await registry.exit(this.props.domainData.listingHash)
      this.setState({
        doneWithdrawing: true
      })
      PubSub.publish('DomainProfileActionContainer.getData')
      PubSub.publish('DomainProfileStageMap.updateStageMap')
      try {
        calculateGas({
          domain: domain,
          contract_event: true,
          event: 'exit',
          contract: 'registry',
          event_success: true
        })
      } catch (error) {
        console.log('error reporting gas')
      }
    } catch (error) {
      console.error('Domain In Registry Container Withdraw Listing Error: ', error)
      PubSub.publish('TransactionProgressModal.error')
      try {
        calculateGas({
github symlex / symlex / frontend / src / common / api.js View on Github external
}, function (error) {
    if(console && console.log) {
        console.log(error);
    }

    let errorMessage = "An error occurred - are you offline?";
    let code = error.code;

    if(error.response && error.response.data) {
        let data = error.response.data;
        code = data.code;
        errorMessage = data.message ? data.message : data.error;
    }

    Event.publish("ajax.end");
    Event.publish("alert.error", errorMessage);

    if(code === 401) {
        window.localStorage.clear();
        window.location = "/";
    }

    return Promise.reject(error);
});
github voluntarily / vly2 / server / api / personalGoal / personalGoal.lib.js View on Github external
const addPersonalGoalGroup = async (group, personId) => {
  const goalSet = await Goal.find({ group }).select('name').exec()
  if (!goalSet.length) return

  const pgs = goalSet.map(goal => {
    return {
      person: personId,
      goal: goal._id
    }
  })
  const personalGoalGroup = await PersonalGoal.create(pgs)
    .catch((err) => console.error('Unable to create personalGoals:', err))
  PubSub.publish(TOPIC_GOALGROUP__ADD, personalGoalGroup)

  return personalGoalGroup
}
github AdChain / AdChainRegistryDapp / src / components / single_domain / DomainChallengeContainer.js View on Github external
try {
        let data = {
          domain,
          listingHash,
          stake: minDeposit,
          action: 'challenge'
        }
        if (isMobile()) {
          let data = ''
          if (reason.length < 15) {
            toastr.error("Challenge reasoning has 15 character minimum")
            return
          }
          await registry.challenge(listingHash, data)
          await createPostChallenge(domain, reason)
          PubSub.publish('DomainProfile.fetchSiteData')
        } else {
          PubSub.publish('RedditConfirmationModal.show', data)
        }

      } catch (error) {
        console.log("error", error)
        toastr.error('Error')
      }
    } else {
      toastr.error('Domain not in application')
    }
  }
github igorski / efflux-tracker / src / js / controller / InstrumentController.js View on Github external
InstrumentController.update();
            break;
        case View.EVENTS.CACHE_OSC:
            cacheOscillatorWaveForm( model.instrumentRef.oscillators[ model.activeOscillatorIndex ]);
            break;
        case View.EVENTS.SELECT_PRESET:
            handlePresetSelect( /** @type {string} */ ( optPayload ));
            break;
        case View.EVENTS.SELECT_INSTRUMENT:
            model.instrumentId = /** @type {number} */ ( optPayload );
            InstrumentController.update();
            break;
        case View.EVENTS.SAVE_PRESET:
            const newPresetName = /** @type {string} */ ( optPayload );
            if ( newPresetName.trim().length === 0 ) {
                Pubsub.publish( Messages.SHOW_ERROR, Copy.get( "ERROR_NO_INS_NAME" ));
            }
            else {
                model.instrumentRef.presetName = newPresetName;
                if ( model.saveInstrument( ObjectUtil.clone( model.instrumentRef ) )) {
                    Pubsub.publish( Messages.SHOW_FEEDBACK, Copy.get( "INSTRUMENT_SAVED", newPresetName ));
                    updatePresetList();
                }
            }
            break;
        case View.EVENTS.SET_TUNING:
            handleTuningChange( optPayload.type, optPayload.value );
            break;
        case View.EVENTS.CLOSE:
            handleClose();
            break;
    }
github AdChain / AdChainRegistryDapp / src / components / sidebar / MainSidebar.js View on Github external
           PubSub.publish('WelcomeModal.open')} activeClassName='active'>Welcome
github igorski / efflux-tracker / src / js / view / PatternTrackListView.js View on Github external
let slot = 0;

    if ( el && el.startContainer ) {
        let startContainer = el.startContainer;
        if ( !( startContainer instanceof Element && startContainer.parentElement instanceof Element ))
            startContainer = startContainer.parentElement;

        if ( startContainer.classList.contains( "moduleValue" ))
            slot = 3;
        else if ( startContainer.classList.contains( "moduleParam" ))
            slot = 2;
        else if ( startContainer.classList.contains( "instrument" ))
            slot = 1;
    }
    editorModel.activeSlot = slot;
    Pubsub.publish( Messages.HIGHLIGHTED_SLOT_CHANGED );
}
github tuwq / blog / blog_front / src / base / general / Player / Player.jsx View on Github external
search() {
      let $fullPlayer = $(this.$fullPlayer.current)
      PubSub.publish(global.PlaySearchReadySubscribe,()=>{
        $fullPlayer.toggleClass('showSearch')
        if(!$fullPlayer.hasClass('showlist')){
            $fullPlayer.toggleClass('showlist')
            $(this.$barIcon.current).toggleClass('active')
        }
      });
    }
github igorski / efflux-tracker / src / js / controller / MenuController.js View on Github external
function handleSave( aEvent )
{
    const song = efflux.activeSong;

    if ( isValid( song )) {
        efflux.SongModel.saveSong( song );
        Pubsub.publish( Messages.SHOW_FEEDBACK, Copy.get( "SONG_SAVED", song.meta.title ));
        Pubsub.publish( Messages.SONG_SAVED, song );
    }
}