Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

state.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.addEventHandler =
  6. exports.dispatchSync =
  7. exports.dispatch =
  8. exports.setState =
  9. exports.getState =
  10. exports.resetState =
  11. exports.ROOT_DESCRIBE_BLOCK_NAME =
  12. void 0;
  13. var _eventHandler = _interopRequireDefault(require('./eventHandler'));
  14. var _formatNodeAssertErrors = _interopRequireDefault(
  15. require('./formatNodeAssertErrors')
  16. );
  17. var _types = require('./types');
  18. var _utils = require('./utils');
  19. function _interopRequireDefault(obj) {
  20. return obj && obj.__esModule ? obj : {default: obj};
  21. }
  22. /**
  23. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  24. *
  25. * This source code is licensed under the MIT license found in the
  26. * LICENSE file in the root directory of this source tree.
  27. */
  28. const eventHandlers = [_eventHandler.default, _formatNodeAssertErrors.default];
  29. const ROOT_DESCRIBE_BLOCK_NAME = 'ROOT_DESCRIBE_BLOCK';
  30. exports.ROOT_DESCRIBE_BLOCK_NAME = ROOT_DESCRIBE_BLOCK_NAME;
  31. const createState = () => {
  32. const ROOT_DESCRIBE_BLOCK = (0, _utils.makeDescribe)(
  33. ROOT_DESCRIBE_BLOCK_NAME
  34. );
  35. return {
  36. currentDescribeBlock: ROOT_DESCRIBE_BLOCK,
  37. currentlyRunningTest: null,
  38. expand: undefined,
  39. hasFocusedTests: false,
  40. hasStarted: false,
  41. includeTestLocationInResult: false,
  42. parentProcess: null,
  43. rootDescribeBlock: ROOT_DESCRIBE_BLOCK,
  44. testNamePattern: null,
  45. testTimeout: 5000,
  46. unhandledErrors: []
  47. };
  48. };
  49. const resetState = () => {
  50. global[_types.STATE_SYM] = createState();
  51. };
  52. exports.resetState = resetState;
  53. resetState();
  54. const getState = () => global[_types.STATE_SYM];
  55. exports.getState = getState;
  56. const setState = state => (global[_types.STATE_SYM] = state);
  57. exports.setState = setState;
  58. const dispatch = async event => {
  59. for (const handler of eventHandlers) {
  60. await handler(event, getState());
  61. }
  62. };
  63. exports.dispatch = dispatch;
  64. const dispatchSync = event => {
  65. for (const handler of eventHandlers) {
  66. handler(event, getState());
  67. }
  68. };
  69. exports.dispatchSync = dispatchSync;
  70. const addEventHandler = handler => {
  71. eventHandlers.push(handler);
  72. };
  73. exports.addEventHandler = addEventHandler;