Skip to content

Instantly share code, notes, and snippets.

Explanation

  • The code defines a StoreProvider component that is intended to be used as a top-level component in a React application to manage the global state.
  • The component uses the React Hooks useState to initialize the state with the initialData prop passed in and to manage updates to the state using the dispatch method.
  • The component also defines three methods for working with a pub-sub pattern: publish, subscribe, and unsubscribe.
  • publish(topic: string, args: any) : this method will take in a topic and data, it will log the topic with the data being published and it will search for the subscribers of the topic if any, and call the callback for all the subscribers
  • subscribe(topic: string, func: (topic: string, data: any) => void) : this method will take in a topic and callback function, it will log the topic the client has subscribed to and it will save the topic and the callback along with unique token to know which subscription is which and which subscription to unsubscribe later.

>* uns

router.get('/posts',authenticate, async (req,res) => {
//const _ispublished = req.query.published;
const match = {}
const sort = {}
if(req.query.published){
match.published = req.query.published === 'true'
}
if(req.query.sortBy && req.query.OrderBy){
import { sum } from '../../src/foo'
describe('TypeScript spec', () => {
it('works', () => {
cy.wrap('foo').should('equal', 'foo')
})
it('calls TS source file', () => {
expect(sum(1, 2, 3, 4)).to.equal(10)
})
//We're running the npm-run-all package to run the scripts independently for TDD/BDD test cases without dockerization and can help in to CI pipelines without overhead of getting all the scripts running sequentially or serially.
//This will parallely execute all the test-scripts files
"app-one": "cypress open --env configFile=script-one.local.json, isCI=false --config video=false"
"app-two": "cypress open --env configFile=script-two.local.json, isCI=false --config video=false"
"app-three": "cypress open --env configFile=script-three.local.json, isCI=false --config video=false"
"run-all-scripts-parallel": "npm-run-all --parallel app-two app-three"
533 minikube status
534 kubectl version
535 kubectl get nodes
536 kubectl api-resources
537 kubectl api-versions
538 clear
539 kubectl get pods
540 kubectl get deployments
541 kubectl run nginx --image=nginx
542 kubectl get pods
it.only('Cowin State Chooser', function () {
cy.intercept('GET', '**/location/districts/2').as('Location');
cy.visit('https://www.cowin.gov.in/home');
cy.xpath("//div[text()='Search by District']")
.scrollIntoView({ offset: { top: -200, left: 0 }, easing: 'linear', duration: 1000, })
.should('be.visible').click();
cy.xpath("//mat-select[@formcontrolname='state_id']//div[contains(@class,'mat-select-arrow-wrapper')]")
.should('be.visible').click();
function client(endpoint, customConfig = {}) {
const config = {
method: 'GET',
...customConfig,
}
return window
.fetch(`${process.env.REACT_APP_API_URL}/${endpoint}`, config)
.then(async response => {
const data = await response.json()
{
"_id" : ObjectId("5f9a940f9d32533a3dc9b2d6"),
"gender" : "male",
"name" : {
"first" : "john",
"last" : "doe"
},
"location" : {
"coordinates" : {
"latitude" : "-10.5930",
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
{
"_id" : ObjectId("5f9a940f9d32533a3dc9b2d6"),
"gender" : "male",
"name" : {
"first" : "john",
"last" : "doe"
},
"location" : {
"coordinates" : {
"latitude" : "-10.5930",