【前端】Neo4j前端源代码阅读笔记

发布时间:2020-06-15 23:31:06 作者:对唔住
来源:网络 阅读:2013

目的

详细

先从代码输入框入手,找到Editor.jsx文件

/// vim src/modules/Editor/Editor.jsx
          <EditorButton
            data-testid='submitQuery'
            onClick={() => this.execCurrent()}
            disabled={this.getEditorValue().length < 1}
            title='Play'
            icon={controlsPlay}
          />
execCurrent () {
    this.props.onExecute(this.getEditorValue())
    this.clearEditor()
    this.setState({
      notifications: [],
      historyIndex: -1,
      buffer: null,
      expanded: false
    })
  }
    onExecute: cmd => {
      const action = executeCommand(cmd)
      ownProps.bus.send(action.type, action)
    }

追踪executeCommand函数到commandsDuck.js

/// vim commandsDuck.js
// 这个文件定义了很多前后端连接的函数
handleCommandEpic() { }

然后是Graph.jsx

 initGraphView () {
    if (!this.graphView) {
      let NeoConstructor = graphView
      let measureSize = () => {
        return {
          width: this.svgElement.offsetWidth,
          height: this.getVisualAreaHeight()
        }
      }
      this.graph = createGraph(this.props.nodes, this.props.relationships)
      this.graphView = new NeoConstructor(
        this.svgElement,
        measureSize,
        this.graph,
        this.props.graphStyle
      )
      this.graphEH = new GraphEventHandler(
        this.graph,
        this.graphView,
        this.props.getNodeNeighbours,
        this.props.onItemMouseOver,
        this.props.onItemSelect,
        this.props.onGraphModelChange
      )
      this.graphEH.bindEventHandlers()
      this.props.onGraphModelChange(getGraphStats(this.graph))
      this.graphView.resize()
      this.graphView.update()
    }
  }

这个文件中出现了createGraph(this.props.nodes, this.props.relationships)这个重要的语句
追踪relationships到VisualizationView.jsx

  populateDataToStateFromProps (props) {
    const {
      nodes,
      relationships
    } = bolt.extractNodesAndRelationshipsFromRecordsForOldVis(
      props.result.records
    )

这个文件中说明了relationshipsnodes的来源
接着是bolt.js

function setupBoltWorker (id, workFn, onLostConnection = () => {}) {
  const workerPromise = new Promise((resolve, reject) => {
    const work = boltWorkPool.doWork({
      id,
      payload: workFn,
      onmessage: msg => {
        if (msg.data.type === BOLT_CONNECTION_ERROR_MESSAGE) {
          work.finish()
          onLostConnection(msg.data.error)
          return reject(msg.data.error)
        }
        if (msg.data.type === CYPHER_ERROR_MESSAGE) {
          work.finish()
          reject(msg.data.error)
        } else if (msg.data.type === CYPHER_RESPONSE_MESSAGE) {
          work.finish()
          resolve(addTypesAsField(msg.data.result))
        } else if (msg.data.type === POST_CANCEL_TRANSACTION_MESSAGE) {
          work.finish()
        }
      }
    })
  })
  return workerPromise
}
推荐阅读:
  1. WEB前端学习笔记 三
  2. if 我是前端团队 Leader,怎么制定前端协作规范?

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

d3 neo4j 图数据库

上一篇:xtrabackup2.4 备份Precona5.6数据库,做增量备份与还原

下一篇:ASP.NET—002:GridView手动增加一行

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》