标签: watch

在XCode 6中,如何在不停止执行的情况下设置观察点?

您可以通过以下步骤在XCode中轻松设置观察点(顺便提一下,如果有更简单的方法,我想知道它......):
- 运行程序
- 在使用变量的代码中设置断点
-到达断点时,右键单击变量并选择"Watch"nameOfTheVariable"'
- 继续执行.

唯一的问题是每次变量值改变时执行都会停止.我希望XCode继续执行而不停止,即只显示控制台输出中的值更改.
这个功能似乎在命令行模式下可用,虽然我最初想避免它,但是我发布了一个使用该模式的解决方案(见下文),因为它似乎是我想要的唯一方法,即在显示变量时继续执行变化.

xcode watch watchpoint

9
推荐指数
1
解决办法
5768
查看次数

eslint 观察任务重复运行

我正在尝试使用以下方法在文件更改时使用 eslint 对我的文件进行 lint 处理npm scripts

"scripts": {                                                                   
  "lint": "eslint ./* lib",                                                    
  "lint:watch":"watch 'npm run lint' .",                                       
  "test": "echo \"Error: no test specified\" && exit 1"                        
}
Run Code Online (Sandbox Code Playgroud)

我使用watch包来完成此任务。

我发现监视任务无限循环运行。eslint 是否写入应用程序根目录中的文件。如果是这样,我怎样才能教 watch 忽略eslint.

我的.eslintrc,如果有必要的话:

{                                                                                
   "parser":"babel-eslint",                                                        
   "extends":"eslint:recommended",                                                 
   "rules":{                                                                       
      "strict":2,                                                                  
      "no-var":2,                                                                  
      "prefer-template":2,                                                         
      "prefer-arrow-callback":1,                                                   
      "prefer-rest-params":2,                                                      
      "prefer-spread":2,                                                           
      "object-shorthand":1,                                                        
      "no-duplicate-imports":2,                                                    
      "no-confusing-arrow":2,                                                      
      "comma-dangle":0                                                             
    }                                                                              
 }        
Run Code Online (Sandbox Code Playgroud)

javascript watch node.js eslint package.json

9
推荐指数
1
解决办法
1万
查看次数

Gulp watch终止或构建整个任务链

我正在使用以下构建步骤开发一个打字稿项目:

  • 皮棉
  • 建立
  • 测试

我使用Gulp 4.0作为构建工具,并希望有一个监视任务,它应该触发测试(这意味着先前触发了lint和构建任务).目前,当发生错误(例如lint错误)时,监视任务终止.

这个问题是众所周知的并且易于解决.典型的解决方案是a)防止错误或b)修补管道行为.

a)对于gulp-tslint,我可以在他们的主页上使用这个配置:

gulp.task("invalid-noemit", () =>
    gulp.src("input.ts")
        .pipe(tslint())
        .pipe(tslint.report("prose", {
          emitError: false
        }))
);
Run Code Online (Sandbox Code Playgroud)

但是当我包含该emitError标志时,会记录lint错误并执行所有后续gulp任务(构建,测试).

b)我也可以gulp-plumber手动使用或捕获错误(参见此处),但所有这些已知解决方案的行为都是相同的,执行以下gulp任务(构建,测试).

我想要的是任务链在发生错误后停止(在lint错误之后没有构建和测试),但是watch任务应该永远不会停止.我该怎么解决这个问题?观察者任务看起来像这样:

// watcher
gulp.task('watch', gulp.series('test', function doWatch() {
    gulp.watch([
        config.paths.sourcePattern,
        config.paths.testPattern,
        'gulpfile.js'
    ], gulp.parallel('test'));
}));
Run Code Online (Sandbox Code Playgroud)

你可以在gulpfile.js 这里找到完整的.

watch typescript gulp

9
推荐指数
1
解决办法
606
查看次数

角度,打字稿变化检测输入文本

我找不到简单易用的解决方案来检测文本字段中的更改。我不想使用,(keypress)因为用户有时会将值粘贴到字段中。(onchange)仅在用户模糊场时才起作用。我想立即发现变化。

什么是最简单的angular js $ watch等价物?

onchange watch typescript angular

9
推荐指数
1
解决办法
7896
查看次数

正确使用kubernetes手表的方法

我是Kubernetes的新手,我不确定如何正确实施手表; 特别是我不确定如何处理resourceVersion参数.

目标是观察具有特定标签的新pod,如果出现错误或从群集断开,则可以从上次发生的事件重启手表.

我正在做这样的事情:

// after setting up the connection and some parameters
String lastResourceVersion = null; // at beginning version is unknown
while (true) {
  try {
    Watch<V1Pod> watcher = Watch.createWatch(
            client,
            api.listNamespacedPodCall(namespace, pretty, fieldSelector, labelSelector, lastResourceVersion, forEver, true, null, null),
            new TypeToken<Watch.Response<V1Pod>>() {}.getType()
    );
    for (Watch.Response<V1Pod> item : watcher) {
      //increment the version
      lastResourceVersion = item.object.getMetadata().getResourceVersion();
      // do some stuff with the pod
    }
  } catch (ApiException apiException) {
    log.error("restarting the watch from "+lastResourceVersion, apiException);
  }
}
Run Code Online (Sandbox Code Playgroud)

使用Pod的resourceVersion重新初始化观看调用是否正确?此数字是群集中所有事件的时间戳,还是不同的api将使用不同的序列? …

watch kubernetes

9
推荐指数
1
解决办法
2116
查看次数

使用Visual Studio 2005调试时调用函数?

这里有一些我认识的可能是可能但我从未设法做过
在VS2005(C++)中,在调试时,能够从我正在调试的代码中调用一个函数.
在调试复杂数据结构时,此功能有时是必不可少的,这些数据结构只能使用监视窗口的常规功能轻松探索.
监视窗口似乎允许编写函数调用,但每次我尝试它时都会给我一个错误或另一个错误.

Error: symbol "func" not found
Error: argument list does not match function
Error: member function not present

有没有人成功地使这项工作正常?我在这里错过了什么?

编辑:显然,调用的函数应该是调试器所在的当前范围中存在的符号.

c++ debugging watch visual-studio visual-c++-2005

8
推荐指数
1
解决办法
6859
查看次数

Angularjs - 在控制器范围内使用orderby过滤器

我有一个对象数组,即过滤和分页,现在我想按不同的对象属性排序列表项.

我尝试orderBy过滤器如下:

<th><a href='' ng-click="reverse = sortParam == 'title' && !reverse; sortParam = 'title'">Title</a></th>

<tr ng-repeat="item in pagedItems|filter:filterParam|orderBy:sortParam:reverse">
    <td>{{ item.title }}</td>
</tr>
Run Code Online (Sandbox Code Playgroud)

这似乎工作正常,单击Title链接,按字母顺序排序或按字母顺序反转,具体取决于当前状态.

但这里的问题是只有pagedItems正在排序,这是有意义的,因为我们正在应用orderBy过滤器pagedItems.我想要实现的是在应用过滤器时订购整个项目集(不仅仅是当前分页的项目).

为了实现这一点,我想我会在控制器范围内使用一种方法.所以我把上面改为:

/** In the Template */

<th><a href='' ng-click="sortItems('title')">Title</a></th>

<tr ng-repeat="item in pagedItems|filter:filterParam">
    <td>{{ item.title }}</td>
</tr>


/** In the Controller */

$scope.sortItems = function(value) {
    $scope.filtered = $filter('orderBy')($scope.filtered, value);
};

$scope.$watch('currentPage + numPerPage + filtered', function() {
    $scope.pagedItems = getPagedItems($scope, 'filtered');
});
Run Code Online (Sandbox Code Playgroud)

sortItems方法工作并更改顺序,但视图中的项目未更新,因为 …

pagination watch angularjs angular-ui angularjs-orderby

8
推荐指数
1
解决办法
2万
查看次数

如何观察使用ng-bind-html创建的ng-model

我需要一些使用ng-bind-html创建的ng模型的帮助.我在服务器中有一个JSON文件,其中有一些html和一些像这样的输入:

*以.json

{  
  "test": {
    "1": {
      "question":"<span>1. something:</span>",
      "options":"<input type='radio' name='q1' ng-model='q.1' value='a'>a) op 1<br><input type='radio' name='q1' ng-model='q.1' value='b'>b) op 2<br><input type='radio' name='q1' ng-model='q.1' value='c'>c) op 3<br><input type='radio' name='q1' ng-model='q.1' value='d'>d) op 4<br><input type='radio' name='q1' ng-model='q.1' value='e'>e) op 5<br>",
      "answer":"c"
    },
    "2": {
        ...
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

然后在我的HTML文件中,我有类似的东西:

<div class="testContent">
        <div class="test">
            <div class="questions" ng-repeat="qs in questions" ng-show="questions.length">
                <div ng-bind-html="qs.question"></div>
                <div class="options" ng-bind-html="qs.options">
                </div>
            </div>
        </div>
        <br>
        <div class="nextBtn">
            <a href="#test/6" class="btn btnNext" ng-click="save()"> continue ></a>
        </div>
    </div>
Run Code Online (Sandbox Code Playgroud)

在我的Angular控制器中,我有对JSON文件的ajax调用: …

watch angularjs ng-bind-html

8
推荐指数
1
解决办法
8069
查看次数

AngularJS:从ng-repeat中删除$ watch

我已经构建了一个报告,它使用一组嵌套的ng-repeat指令来创建一个巨大的表.它可以很好地构建表格,但在此之后,滚动性能受到很大影响 - 我认为这是由ng-repeats创建的大量手表所必需的.

报告只需要构建一次,然后是静态的.我不需要不断观察数据.

我有两个问题:

A)无论如何看到Angular目前正在观看的所有变量的列表?

编辑:这篇文章是学习如何基准测试的一个很好的帮助

B)无论如何要告诉Angular停止它正在做的所有手表吗?我看过很多关于取消手表的帖子,其中一个是自己设置的,但这些都是原生指令,我不知道我是如何利用它们的.

我的偏好是有一个变量,我可以说"如果真的,然后做所有的手表,如果没有,那么不要看"或只是说"开始观看"和"停止观看"的功能.

我已经建立了一个非常好的DOM观看服务,它可以告诉所有ng-repeats何时执行,所以我可以知道我何时想停止观看.

这是表本身.除了tk-ng-repeat-completed之外,其他"tk-"属性仅用于数据,而不是实际的指令.

<div class="table-responsive">

    <table tk-sticky-column id="records" class="table table-striped table-hover table-condensed">

        <!-- tbody[n] -->
        <tbody class="dataset" ng-repeat="dataset in report.data track by $index" tk-ng-repeat-completed>
            <!-- row[0] -->
            <tr class="headline">
                <!-- header[0] label -->
                <th class="headline" style="background-color:#042E34;">
                    <div style="width:200px;"><h4>{{report.labels.y[$index]}}</h4></div>
                </th>
                <!-- header[n] label -->
                <th ng-repeat="x_label in report.labels.x" tk-ng-repeat-completed
                    class="datapoint date"
                    tk-raw-data="{{x_label}}">
                    <em><small>{{x_label}}</small></em></th>
                <!-- header[last] space for addition @todo remove this, add during calculations -->
                <th class="date"></th>  
            </tr>
            <!-- row[n] --> …
Run Code Online (Sandbox Code Playgroud)

javascript watch angularjs

8
推荐指数
1
解决办法
3916
查看次数

如何在 Vue3 中使用单个观察者观察 ref 和反应对象

Vue v3文档展示了一个通过将数组作为参数传递来使用单个观察者观察多个引用的示例

我可以(以及如何)使用类似的方法通过单个观察者同时观察ref和对象?reactive

const state = reactive({
  postPerPage: 10,
  currentPage: 1,
});

const posts = ref([]);

const currentPosts = ref([]);

watch(
  () => posts.value, // store value in currentPosts when the posts.value is updated (get data from api)
  () => {
    currentPosts.value = getCurrentPost(); 
  }
)

watch(
 () => {
  return { ...state };
 }
 () => {
  currentPosts.value = getCurrentPost();
 }
)
Run Code Online (Sandbox Code Playgroud)

watch vue.js vuejs3

8
推荐指数
1
解决办法
2万
查看次数