Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Request Hooks #65

Closed
Closed
@chriddyp

Description

@chriddyp

The API requests that Dash's front-end makes should be configurable. In order to make them configurable, we will need to do the following things:

  • We will need to make the Dash Front-end (dash-renderer) a standalone library that can be initialized and invoked from other libraries
  • We will need to extend the dash-renderer to take a set of config input parameters
  • Some of these input parameters will be functions or promises that we will call before certain actions
  • For this issue, we will start by a request_pre and request_post parameter that will be called before and after HTTP requests with the entire request and response objects. This will enable the developer to transform the data before and after network requests.
    Example:
dash_renderer({
    request_pre: requestPayload => {
        return modifyRequest(requestPayload);
    },
    request_post: (requestPayload, responsePayload) => {
        return modifyResponse(requestPayload, responsePayload)
    }
})

So, the hooks are only the network requests. In the code, this would fit in here:

return fetch(`${urlBase(config)}_dash-update-component`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': cookie.parse(document.cookie)._csrf_token
},
credentials: 'same-origin',
body: JSON.stringify(payload)
}).then(function handleResponse(res) {

Note that in order for users to supply their own arguments, I believe they would need to provide their own instance of dash_renderer by overriding the index file (as discussed here: plotly/dash#265)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions