The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/providers/RouterProvider.js

29 lines
985 B

import { FlowRouter } from 'meteor/kadira:flow-router';
import React from 'react';
import { RouterContext } from '../contexts/RouterContext';
import { createObservableFromReactive } from './createObservableFromReactive';
const navigateTo = (pathDefinition, parameters, queryStringParameters) => {
FlowRouter.go(pathDefinition, parameters, queryStringParameters);
};
const replaceWith = (pathDefinition, parameters, queryStringParameters) => {
FlowRouter.withReplaceState(() => {
FlowRouter.go(pathDefinition, parameters, queryStringParameters);
});
};
const getRouteParameter = createObservableFromReactive((name) => FlowRouter.getParam(name));
const getQueryStringParameter = createObservableFromReactive((name) => FlowRouter.getQueryParam(name));
const contextValue = {
navigateTo,
replaceWith,
getRouteParameter,
getQueryStringParameter,
};
export function RouterProvider({ children }) {
return <RouterContext.Provider children={children} value={contextValue} />;
}